You can use your eSIM for iMessages.
Please keep in mind that you may need to reset iMessage after installing your eSIM. You can do so by following the steps below:
1. Go into Settings.
2. Scroll down until you see "Messages"
3. Toggle iMessage "OFF"
4. Toggle iMessage back to "ON"
5. Tap on "Send & Receive"
6. Uncheck your number and make sure your email address is checked. This way, you’ll be able to send and receive iMessages with only a data connection.
When you no longer have a need for your eSIM or it runs out, and you wish to switch back to your Primary SIM, you can do so by following these steps:
Settings > Messages > Send & Receive and check your phone number again.