Just thinking about this for a minute or so, I don't think there's a way of allowing /only/ one door to remain open-able ('unlocked') that solves the problem. Either both must lock/unlock in the same action or there must only be one door to the restroom (that is, duplicate the resource).
If the two people are accessing the bathroom from the same side, locks are not a problem. Three or more people sharing the bathroom is a different problem.