Of course, it may depend from sensor to sensor, but the Xiaomi Aqara advertised here is rated at IP67. If you look up the IP ratings and what they mean, you find that the first numeral digit refers to its imperviousness to solids, and the second refers to its resistance to water.
A rating of 6 on solids means that it has:
Protection from contact with harmful dust.
A rating of 7 on liquids means that it is:
Protected from immersion in water with a depth of up to 1 meter (or 3.3 feet) for up to 30 mins.
Given that you're not submerging it anything like a meter, it should be fine at whatever angle you put it at - especially if you arrange it such that you can remove it from the bathtub once you get there to turn the water off. Leaving it sitting in the water for extended periods of time might not be the best, as it is only verified up to 30 minutes.
Hope this helps!