First of all, you’re not alone. One estimate is that about 17 million men in the US experience “bashful bladder syndrome” to one degree or another. The medical term for it is paruresis. If you find yourself standing at a urinal with nothing coming out because some guy is peeing right next to you, try bearing down on your bladder as though you’re having a bowel movement. The extra pressure can sometimes trigger the urination reflex. You can also, of course, just use a toilet stall so you can urinate in private. But if you’re really bothered by your inability to pee next to other guys, or you find yourself avoiding certain social situations because of it, see your doctor.
Some kinds of cognitive-behavioral therapy have been shown to help this condition. And if your paruresis is related to an anxiety disorder, you may also find relief with an anti-anxiety, or anti-depressant medication.