I used to be unable to pee in public restrooms if anyone else was around, although I had a little more luck if it was someone I knew. My friend was the opposite. He was fine with strangers but had trouble with friends nearby!
I can tell you that it becomes easier as you get older. It hardly bothers me at all any more. For whatever reason, I just don't care any more so I don't get that intense anxiety that I used to get. Much nicer.
It might have to do with being married too. My wife does not shut the door when using the bathroom and feels free to come in if I am in there. That eventually helped me reduce the related anxiety too. Plus all of the fun stuff married people tend to do gets you less shy about things and reduces the anxiety.
Another thing that can help is finding a 'pee' buddy who you are able to talk to about the issue and then going to pee together. If you can talk about it you'll find it isn't as awkward as you would think. It is kind of liberating. You can both drink a lot of fluids and then agree to stand around as long as it takes until you both go. Eventually the anxiety decreases and you actually can. Then celebrate!
BTW, most people with this condition avoid drinking liquids but that can eventually cause kidney stones, which are no fun, so do yourself a favor and work on the problem so you can drink enough liquids that your urine is mostly clear and not yellow. I know that is uncomfortable and a pain, but it will help you get over the issue too!