I'm replacing an old doorbell transformer. After removing the junction box, I have 3 exposed black wires. I have the new transformer with the typical White, Black, Green wiring, but I don't know which wires - if any - to connect the green. I added a photo. Any help would be appreciated.
The bare grounds are buried in the bottom of the box there
Since these are NM-type cables we're dealing with here, the ground wires in the box will be bare wires, and lo and behold, there's a whole bundle of them improperly spliced together in the bottom of the box. Take a suitably sized wirenut and nut the green wire on your transformer to that bundle of bare wires (this will also properly splice the bare grounds to each other).
As to the hots and neutrals
The black wires in this box are all hot, and the white wires are all neutral (otherwise, there'd be a white spliced to something that isn't white, that's a clue that shenanigans are afoot). So, in this case, it's black nutted to black, white nutted with whites (and you may wish to replace the splice of the existing neutrals with a proper one while you're at it), and grounds as above.