Can I add a second junction box to house a doorbell transformer?
It sounds like you have the transformer wired on the switch loop so the switch position makes a difference. If you move the door bell to the light feeder it will work as it should. Can you add another box and provide a dedicated circuit? Yes, but this would be quite expensive and really not needed for such a small load.