@quixoticgeek There is a type of locomotive here in Queensland that was upgraded with onboard toilets. However they're at the long hood end (opposite from the driver's cab). As per a retired driver I know, the main freight operator does not allow drivers (there's normally two) to use them while the train is moving. So sometimes signal stops become extended 'comfort stops'.
I video these trains quite often and just found a video of mine with a loco where the toilet door is open. You can see it at about 17 seconds in.

@quixoticgeek American style locomotives use the area under the nose for theirs, The local to me (Queensland) trains tend to have them in a little room just behind the co-driver's seat
But yes, many locomotives do have toilets for the crew
@quixoticgeek I know the deltic has a urinal somewhere in the engine area. You probably wouldnt want to use it while the engine is running (they are fucking loud)
Its definitely not a universal thing on all trains though (I see no evidence of such a thing on the HST power car, for example)