I think it's less apparent on other aircraft such as the 777 because I think there's a door parallel to the cockpit door that can be closed to conceal the presence of the forwardmost lav. (There's definitely one on the upper deck of some airlines' 744s.)
But yeah, if I see a pilot come out of a lav and lock the door from the outside, I would be tempted to unlock the door myself once the pilot and any FAs are out of sight.