Can I hide a transformer in a metal box in my cabinet?
From what I can find on the model you cited here.
It is a sealed unit meant for halogen fixtures so it would normally be mounted inside a light fixture or other enclosure anyway. 

Therefore, I don't think you need to worry about heat. But if you are OCD you could epoxy it to the metal cover of the 4" box and the cover would act as a heat sink and radiate away some of the heat.

Good luck!