I've looked at the motorized bicycle laws for about 40 states now. About 2/3 of them treat electric assisted bicycles a good bit more leniently than they do gasoline engined ones, if they recognize a difference at all.
Not one of those states addresses the source of the electricity. NOT ONE. The only things the law addresses is maximum attainable speed under electric drive, and maximum allowable power of the drive system. Typically, that's 20mph on level pavement, and/or various wattage ratings (varying from 200 watts to 1125 watts) and/or horsepower ratings (using 750 watts = one HP).
Since the law does NOT address the source of the electricity to power the bike motor(s), a simple small 2 stroke engine/generator set charging a battery as a power demand modulator is perfectly legal, and any cop who writes a ticket on the basis that the bike is gas powered is on a fool's errand. Sure, you might have to go to court - in which case hold out for a jury trial. Most importantly, know the law in your state, and local jurisdiction; keep a copy of it in your tool pouch, and most courteously offer to share that with the cop who stops you.
Yes, there are losses in such a system. That is unavoidable. They can, however, be made quite small, and since you are charging a battery as a power reservoir, you can set your generator up to charge at its most efficient rpm setting. Very probably, you can offset many of the losses of efficiency from variable throttling of the engine used as a prime mover.