I had a similar sort of problem for a long while, never really found a solution to it though.
When I was at school it wasn't so much of a problem because I wasn't out, and I didn't pass when I was there because the uniform was no tie and a skirt for the people they thought were girls. It was a lot easier to use those toilets as well anyway because there were six bathrooms for "girls" but only three much smaller ones for "boys" in my school. It was a tiny school so everyone knew me, so were only shocked by someone who looked like a guy being in the toilets when I was in sports kit or something and they just caught a brief glance at me and didn't realise who I was.
When I wasn't at school and wearing that stupid uniform though things were a lot harder. I come from a small village where everyone knows me there because I'd lived in the only village pub for 17 years, then there was everyone else who knew me from school and other places. The chances of me seeing someone who might know me, even if I didn't recognise them, was too high for me to risk going in the men's out in public, even if I wasn't with my family who had no idea I was trans. That lead to a couple of pretty awkward moments, with a landlord of a pub physically trying to drag me out of the toilets once, ending in a friend's entire birthday party getting kicked out. I used to try and use disabled/unisex toilets when I could and knew where they all were in the town I was normally in (Subway and the trainstation became good friends of mine!).
At college it was difficult as well though, because only the people in my class thought I was female, everyone else was reading me as male. I used to duck in and out of the toilets at times where the majority of people were in lessons when I was in the main block, but if I was in a different block I'd walk over to the carpentry/boatbuilding block and use the female toilets there. It was too risky for me to use the male toilets in case someone did know me and see me there, but there were barely any females taking those courses so much less likely that I'd come across someone else in the toilets.
The same thing happened at work until I came out as well, there was our company using the training facility, all of whom knew me, but there was also another company who didn't know me. Fortunately although the trousers were pretty much the same colour, the boots we wore weren't, so if someone came into the toilets while I was in the cubicle I used to end up looking under the partition and working out whether they knew me or not by their boots. After I learned to do that it was only going in and out of the toilets that caused problems, mostly with the cleaners. Once I came out I had an awkward week where I was banned from using the male toilets at work to give people time to get used to me being in the toilets in the accommodation before I was in the same place as a urinal, and there was also worries that the Royal Navy (whom we rented the buildings off and sometimes used our facilities) might start an argument if they didn't read me correctly. I used the one disabled toilet on the base, (a mile away, over a bridge and in the mess room) when I was at lunch, but the one day there was a burst water pipe and they were out of order I ended up threatening to pee on the manager's floor, and they soon sorted that out.
Since I've come out and moved away I don't have to worry about coming across anyone who might have known me under the impression that I was female anymore. My struggle now is not having a toilet at work, and everyone else just being able to turn round, whip it out, and pee. I don't want to out myself, so I just watch what I drink.
I've never heard of anyone else getting grief over using the cubicle to have a pee though. You could be pee shy, have a dodgy stream, or just prefer it.