There are old work dual voltage boxes that you could replace the current box with and then use one of the inbox style transformers.
https://www.amazon.com/dp/B0069KOJ48
The requirement is that there is a UL listed barrier between the high voltage (120V wall power) and the 24V doorbell power side of things.
I have seen listed single gang boxes that have a barrier plate that goes in the middle of the box between the top and bottom half allowing the low voltage wires to pass from one side to the other. The wires that pass through the barrier have to be rated to the high voltage standard.