Short answer
You can buy and install the eSIM before your trip, but it usually connects only after you arrive in a supported destination and the phone reaches a local network.
Recommended timing
Buy before your trip if you want to prepare in advance.
Install while you have stable Wi-Fi.
Do not delete the eSIM after installation.
Expect it to connect after arrival in the supported destination.
Before arrival
It may show Activating, No Service, or no signal. This can be normal before the eSIM reaches a supported local network.
After arrival
Make sure:
the eSIM line is turned ON;
it is selected for Mobile Data / Cellular Data;
Data Roaming is ON for the eSIM.