Hybrid sailboats are already a thing. An electric motor/generator sits in line with the traditional diesel engine and can a) drive the prop shaft, b) harvest power when the engine is turning the prop shaft, c) generate power by running the engine with the prop shaft clutch disengaged, or d) (the one you’re getting at) passively generate power when under sail by disengaging the clutch from the engine side and letting the prop spin the generator.
Sailboat props are often variable pitch to allow for better efficiency (i.e. they can be turned completely parallel with the flow of water when not in use), which also allows them to be set at an optimal angle for power generation (with minor speed losses, obviously).