Yep, that's how a "dynamo torch" works.
They have a tiny generator turned via gears from a crank handle, plus a rechargeable battery.
Example:
https://www.clasohlson.com/uk/Varta-LED-Dynamo-Torch/36-3739
Another version, opened up; you can see the dynamo on the right (probably just a basic permanent magnet DC motor used as a generator) and the battery on the left, with the green insulating sleeve:
http://brainmedley.com/blog/wp-content/uploads/2008/08/geartrain.jpg
You can also get eg. wind-up radios that run from a little dynamo.
On a larger scale, that's how a car electrical system works - a dynamo (or now alternator) powered by the engine, that charges the vehicle battery and also runs the electrical system while the engine is running.
A dynamo or alternator is just a combination of coils and magnetic field, one rotating relative to the other.