I may be having a brain f*rt but I can't find the code section that prevents burying a doorbell transformer in the wall. 460.1 ex 4 seems to take that whole article out of the mix. Chapter 3 is out for 725 circuits and I don't see anything in 725
I encountered this situation years ago in some new houses we were wiring in extreme northwest New Jersey. They were 100% finished homes on slabs, no unfinished space whatsoever. No furnace, no boiler, just electric baseboard heat. My boss insisted upon just putting the transformer inside the panel and keeping the amount of exposed bell wire inside the panel to a minimum.
Obviously, this didn't fly with the inspector. He suggested what seemed to do well as a work-around. We attached the transformer to the bottom of the panel using the attached nipple and locknut, then we placed a two-gang mud ring to the stud below that permitted full access to the transformer. A two-gang blank plate finished it up.
Not exactly the best way to do it, but it satisfied the inspector for access.
Thinking along this, the xfr under the panel w/mud ring could be an issue, if... Wall cavity is to be insulated. Usual panel location is a garage, outside wall. The electrical inspector sees rough before insulation, and final when all is said & done.