Yes peeing in a lake while swimming is perfectly okay.
I've went swimming in lakes in swimming shorts and just peed in the lake when needed and didn't get out of the lake to pee.
Your urine is pretty sterile and the lake will naturally filter your pee as the lake water moves around.
There's nothing bad about peeing in a lake when you're in the lake.
Just don't poop in the lake because you would not want to poop in your pants or shorts anyway.
But if you need to pee while in the lake or ocean or even your own swimming pool it's perfectly fine to do so.
I would not pee though in a public swimming pool but in a lake, ocean or your own swimming pool it's fine.