One of the steps of preparing the cabin for landing is checking that all passengers are seated and buckled up, and no passengers are using the toilets and toilets are locked (it can be [un]locked from outside). The reasons behind checking the toilets for passengers during landing and takeoffs are related to safety and security.
The safety related reasons are obvious, landings can be hard and you sitting in the toilet can be dangerous. Security related reasons are also obvious, the aircraft is closer to the land and it is over a city, which makes the sabotage plans have bigger effects.
What will the crew do
- The crew will knock on the door, and ask you to come out.
- They can also unlock the door from outside and open it.
- They can remove the whole door easily if you were to keep locking it from inside (lavatory doors are equipped for this).
- The crew will also inform the captain about the situation, depending on the crew judgment, they can call security upon arrival, or call the onboard air marshal.
What should you do
- DO NOT resist by any means, not verbally and not physically.
- If they ask you what are you doing, tell them the reason clearly, do not say vague stuff like "I do not feel well", just say it clearly, something like "I have diarrhea".
- If they want to open the door to make sure, open it for them, if they try to open the door from outside, do not resist it. Most likely they will take a quick peek and close the door.
Once they are sure you are simply doing nothing wrong, they won't escalate it.
Remember, the cabin crew will deliver the message to the captain depending on the first impression they get, that impression can be a threat impression, or a a guy with bad stomach impression. The captain will react according to the first call since it is a landing which is considered a critical phase in the airlines business, the reaction can be as extreme as declaring an emergency landing, or as simple as "tell the guy to hang on to something".
Finally, the reaction will be different from one airline to another, country to another, crew to another. In some countries I would expect the reaction to be extreme in the name of security, while in some others (like Asia) the crew might be more understanding. In any case, the crew are humans, and they do understand human needs.