I'm going to be brutally honest with you. If a woman sees your shorts is halfway down your butt and your pubes are showing, she's going to assume you're some kind of sick exhibitionist and she's not going to want to look at you because she's not going to find you attractive.
If a woman DOES find you attractive, she'll look, but she won't ogle. That's just not the way we do it. We're a lot more polite and subtle than guys. And we don't typically stare at the crotch. When I'm at the gym, I subtly check out guys with ripped chest, broad shoulders, nice butt. I don't really stare at the crotch. But if I see a guy trying to let his groin hang out halfway, I'd avoid him.
It's a myth that women aren't visual. We are. If women weren't visual creatures too, then it shouldn't matter if a guy is balding and overweight. And yet we all prefer a guy with a nice body.
However, women only ogle at guys we find attractive while guys will ogle large boobs on basically anyone. If a woman doesn't find you attractive, she's not going to feel inclined to ogle your body parts. I only peek at the bods of guys I have a crush on.
And yes, you CAN get in trouble for it. Most gyms have policies on what's considered descent. If someone reported that you weren't properly dressed while OUTSIDE of the dressing room, you CAN get in trouble.