Yes, you definitely can. A number of our customers have asked this question of the years. A great product for this is Loctite Multi Purpose Repair Putty. It will hold the magnet in place and will also come off. Another option is two sided Gorilla Tape. We’ve used this to hold accelerometers in place without issue. The tape is a bit easier to use and work with.