If we think this through, F1 is the pinnacle of open wheel, single seater car racing and arguably the highest level of any motorsport globally.... There's more... drivers are adults who have dietitians who plan special diets and manage their hydration meticulously, so most of the time they should be able to go for a couple of hours between toilet stops.
But, like anyone, they could get caught out and there is no way that they will stop the car for the time required to exit, go to the bathroom and get back underway.
So, in the case of extreme emergencies, drivers are instructed to pee inside their suits. As is common with other high-performance sports, where a bit of wee isn’t going to get in the way of the prize.