Cover & sound-suppression for doorbell transformer in utility closet
The best way to eliminate transformer noise is to purchase a quality transformer.
The noise is because the laminated core is heavily loaded or overloaded and the plates are actually vibrating because of eddy currents. I can’t quite make out the size, but it looks like 24V, 20VA. I would bump it up to a 24V, 40VA unit that would be compatible with video doorbells and probably a lot quieter. Usually, hard mounting is fine unless the core is coming apart or overloaded so going to a new larger one fixes both problems.