Can I use a magnet to make a hinged mirror stick to the wall?
Why, of course! You're looking for a "magnetic catch".
Just you should possibly install it the other way around - a metal plate on the wall, and the catch screwed on the mirror.

Images added: 


Magnet mounted as plug in the cabinet with large head screw contact
Magnet in cup washer and mating contact washer mounted with screws
Thin magnet to metal plate