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.
Using iMessage with eSIM and Data Only
1. Go into Settings and scroll down until you see Messages.
2. Tap to toggle iMessage off.
3. Tap again to toggle iMessage back to on.
4. Tap on Send & Receive.
5. Uncheck your number and make sure your email address is checked. This way, you will 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 returning to the last step and entering your voice number from your primary SIM.