it has been done, and for most it is still not a cost effective change. Quite a bit of work on all fronts and you need to have room for batteries, controllers and electrical. New engine bed/frame and copious small items. If you have a yard do it, the cost will be even more. Low voltage and high current needs to be respected in every way.
best of luck.
I'd have to disagree after doing the first test run on a friends electric motor install yesterday.
The boat is an older O'Day 28 and he pulled the diesel and replaced it with an electric motor over the winter. He's an engineer and did his homework on purchasing a kit versus sourcing all the parts himself and went with an off the shelf kit. Total cost including batteries was less than a comparable Beta Marine diesel.
The engine and batteries weigh less and take up less room than the diesel and fuel tank. The controller is mounted in the cockpit where the old throttle control was located. He did modify the engine mounts and construct a battery box from 3/4 ply. None of it was beyond a "do it yourself" sailor.
Estimated running time at cruising speed (not full throttle) is about four hours. We couldn't test that "normal" running time yesterday as there was a lot of chop on the bay. Performance was brisk. Docking will take a little practice. We're all used to the slight lag as an engine revs up - with the electric the power is right now, there's no lag.
Whether electric makes sense for you really depends on how you sail. In his case it's 15-20 minutes motoring from his slip until he can raise his sails. His sailing is strictly day sailing on the bay and he can plug in and top off the batteries each night in his slip -- which is how many of us sail anyway.
It wouldn't be the right solution for someone running up and down the ICW, but we have passed the tipping point where electric is a viable option for many weekend sailors.