If you replaced the plastic box with a metal box, this becomes easy.
Metal boxes have round cutouts on them, so a low voltage transformer can mount right on the side.
I do not know enough about plastic boxes, but you might find something to work, but means changing the box anyway.
Might be the reason they used the wall wart instead.
If you change the box, make sure the breaker is off first. Also test for no power/dead circuit before putting your fingers in the box. You test in case you turn off the wrong breaker or the breaker is labelled wrong or it is an older MWBC circuit without handle ties. Either one can make life too interesting.