Yes, you can put a cactus in the bathroom. However, it is important to take into consideration their sharp spines. This can make it a potential risk for your safety.
Cacti thrive in a dry environment, but that doesn't mean a humid bathroom will kill it. However, it is not advised to do so because they will grow at a healthier rate outdoors.
In addition, cacti prefer the soil to be at least six inches deep. If you don't have much space, you should consider growing it outside.