I respond to myself so everybody can know the results of my "experiment".
I've done the test with a pixel 6a, and the response is yes, the eSim is preserved after a factory reset through recovery mode.
So, this is very important: if you don't have activated the "SIM lock" option, a thief that makes a factory reset through recovery mode will have immediate access to your future calls and SMS, and this can be very dangerous if you have to receive SMS with sensitive data or related to two authentication systems.
The steps to reproduce it are:
- Enter to recovery mode. Wipe the device.
- Configure GrapheneOS from scratch.
- Enable eSIM and reboot.
- Now you have the eSIM preserved and you can use it.
By the way, when doing the factory reset I got this message:
—- Wiping data
ERROR:
recovery: [libfs_mgr] Unable to enable ext4 verity
on /dev/b10ck/p1atform/14700000.ufs/by-name/metadata because
/system/bin/tune2fs is missing