I think in that case it makes sense to knock but in most cases if I see a single use bathrooms with the little occupied in red or vacant in green lock indicator on it I’m just gonna assume it’s free if it’s not locked and open it. I haven’t been burned by that yet because in most situations people will lock them when using them.
Personally I think it’s fine to do that. Better that you get that money then either some right wing person who is gonna use it to promote their horrible causes more or some right wing company gets it and does that on a bigger scale.