Probably the best way to excuse yourself from an online class is to use the classic "Oh, the internet was down". The reason why it works all the time is that you have absolutely no control over it. It happens occasionally, especially in under-developed countries functioning without a secure infrastructure. The teacher doesn't have any way to verify your excuse (without calling your parents lol). They'll just have to say okay because there's just no other option.
However, you do need to be careful. You can't make the no-internet excuse if you share social media circles with your teacher. If you're sharing memes on Facebook during the class when you're not supposed to have internet, a teacher will pick up on that pretty quick.
They're lenient. Not dumb.
If your institute doesn't force you to turn on your camera during a class, you're pretty much golden. However, if they do, you can still work around it and go to sleep without much hassle. All you have to do is tell the teacher that your camera is faulty. Stay in the class for the first 10-15 minutes and talk a bit, so the teacher knows you're there and paying attention. Once things settle down, mute the class and go to sleep. There's a 99% chance that the teacher won't even notice you're gone.