That's the general idea behind series plug-in hybrid electric vehicles (PHEVs).
..Gasoline engine acts solely as a generator to recharge the battery, but can't mechanically power the wheels (known as "series hybrids"). Example: BMW i3..
https://www.caranddriver.com/features/a45483659/plug-in-hybr...