Sure, but producing 1kWh worth of petrol doesn't require 1kWh of energy. Producing 1kWh worth of hydrogen through electrolysis always requires more than 1kWh of energy, it's just pure physics. Even if the process was 100% efficient through magic, it's still a stupid thing to rely on for producing hydrogen.
> producing 1kWh worth of petrol doesn't require 1kWh of energy
… so long as you don’t count the 1kWh of photosynthesis that was done by a bunch of ancient plankton to rip CO2 molecules apart and build hydrocarbons instead.
I meant the energy that was originally used to create oil in the first place. You don't need to add any more, because oil, unlike hydrogen, already exists.