Maybe. But if it were me I would use an alternator. It can keep up at idle speeds better than a generator unless the engine is idling rather fast. If I remember right, the alternator usually last longer than a generator, and may give a more constant voltage.
Also, if you add in headlights, tail lights, and heater /ac running at some point the generator may not quite keep up.
But Jerry could certainly answer better than I could about that.