It’s not possible to text without showing online, but you can text indirectly being OFFLINE. Yes, there are two ways
1.When you receive message from some contact or group and you need to reply without modifying your last seem it without showing online, then you can directly reply from one screen. (For iPhone: Just slide the message to left, there you can see “view” option, tap on it and reply) (For Android: Just tap the message on home screen, below that message you will find option as “Mark as read” & “reply”, tap on reply)
2.If you want to send message to new contact in WhatsApp without showing online. Switch phone to airplane mode which will switch off the wifi and data connection. Then open WhatsApp, search the contact for which you want to send message. Open it, Type the message, send it and back to home screen, keeping WhatsApp running in background. Turn off the airplane mode. Now, the message will be sent to receiver in seconds without modifying your last seen and without showing online.