Question: When the pilot or co-pilot need to go to the bathroom, do they exit the flight cabin?
If the answer is yes, that's the time to lock the door and climb.
Yes, they exit, and yes, they can be locked out.
They would not need to go to bathroom one hour after the flight takes off. Certainly the plan could not be dependent on waiting for someone to take a leak. Not enough fuel for that nonsense.