When the battery runs out, you pull over and “pedal” to recharge the battery, then you’re good to go again!
I don’t own one of these, but that sounds actually useful if for example I’m about to climb a big hill and want to pedal at a less strenuous pace (but for more time) than would be needed to overcome the slope.
Assisted modes already exist, and regenerative braking already exist
But do e-bikes have regenerative braking? I haven't seen that. I've been thinking that it would just be too heavy and clunky to be worth it.
Too heavy? You just run the motor in reverse which turns it into a generator and adds friction to do generative braking. There really isn’t any added weight.

Bikes normally have freehubs, a ratchet on the cassette (sprockets) of the rear wheel, when you stop pedalling the bike freewheels, without that the pedals would keep turning.

This makes driving a motor from the wheel impossible without heavily modifying the normal bike mechanics. That’s why regenerative braking on e bikes is rare.

Not if you have a hub motor. Those don’t interact with the gear system at all.

Only very cheap e-bikes have hub motors. They’re not a good idea precisely because they don’t interact with the gearing system. So you lose that functionality.

It’s not worth losing access to gearing just to get regenerative braking because the amount of power being used isn’t worth trying to recoup.

Motors are generators when run inversely:

Motors = put in power to get rotational movement

Generators = put in rotational movement to get power

You already have the heaviest parts on the ebike - motor and battery, just need some capacitors and charging circuit board which are light and not too big.

Cheap electric bikes I’ve ridden with regen breaking slow you down quite a bit.

It’s not difficult to get regenerative braking on a bike it’s just difficult to get regenerative braking on a bike that’s any good. Hub mounted motors are the least efficient type of motor because it’s just directly driving the wheel at whatever speed it can output, with no access to gear ratios. E-bikes that forgo generative breaking in favour of a more efficient motor designs achieve better speeds for any given amount of power usage.

So yeah you can absolutely do it. But it’s not a good idea for reasons that have nothing to do with the weight.