Gyms are very paranoid about this sort of thing. Most of them post signs saying cameras and smartphones are not allowed in the locker room, and if they catch you they will throw you out and cancel your membership.
When you’re undressed in an even remotely public space like a gym locker room, if some perv wants a pic they’re going to get a pic. I’ve dropped gym memberships in the past because homosexuals started hanging around in the locker room. You can’t really control who’s in there I guess, but you can try to control their behavior. I honestly don’t care who looks but if they’re getting sexually aroused it’s very disturbing and I don’t want pictures of my naked self circulating around, somebody I actually know might end up seeing it and think I approved.