That’s a creative idea, I like it!
Magnets corrode easily, so they need to be coated first. What also needs to be adressed is the distance between two magnets or metal. The force exponentially drops with the distance. So a 1-2mm material thickness over the magnet is desireable.
Maybe by creating a two-part piece could help, where one part creates the right hole depth&thickness and the other closes the hole. The magnet could be inserted before the second growing phase, after which you also join the pieces to let them fuse/grow together.