>>2626986unironically, switch from whatever underwear you are wearing onto a type of loincloth, no elastics, tied securely around your waist or hip and firmly holding your genitals, with your penis pointing up so when you get a boner it's not an issue. unless your cock is too long and it pokes past your shorts or trousers, but i assume you are wearing a shirt too so that shouldn't be too much of an issue. you could also angle it if need be but eh.
if masculine old world garments are too much for you, you could alternatively use a chastity cage or some gay shit like that idunno.