If you mean can you use a KO and run the 120 wire in the panel and keep the transformer on outside ,YES
We had a long thread on this a couple weeks ago.
Many of the people that frequent this site may be sick of me saying this, but I'll say it anyway.
Generally speaking, the code is either one of two things (yes, there are some exceptions to this), (1) mandatory: such as "thou shalt do this" or (2) Restrictive: such as "thou shalt not do this..."
With that in mind, a more appropriate question might be: "is there a code section that prohibits the practice of...
door bell xfmrs be directly connected to the panel box with the nipple molded to it?