If you have a proper keep out area in place, it doesn't make any significant difference. "Proper keep out area" means - no metal on any layer of the PCB below the antenna.
The first picture shows a perfectly fine ESP32 positioning - the antenna has a good "ground plane free" area underneath it. Sticking it out will only make your device bigger.
However, if there is no possibility to remove the ground plane below the antenna, it can be a good idea to add that extra length and stick the antenna part out.