Yes, you do need to be connected via wifi or mobile network to purchase a data plan for the first time.
Following purchases can be made even if you are not connected via wifi nor mobile network.
If you are connected via mobile at the time of first purchase, Primary (au line etc.) will be disconnected once during installation for eSIM profile.
If Primary or Subline (Travel Data eSIM line) cannot be connected after a few minutes, you do need to reboot (Power switch OFF and ON) your iPhone.