Large ship engines can be on the order of 10,000-30,000 hp or more. In KW that's 7.5-22MW.
A large cargo ship might be Panamax (https://en.wikipedia.org/wiki/Panamax) and thus 950ft long and 105ft wide or have a total top surface area of 99750 sqft. Commercially available solar panels have an efficiency of around 20% and sunlight is often quoted as 100w/sqft so you might be able to generate 2MW of electricity from covering the entire top of the ship in solar panels. 2MW compared with say 15MW is significant but there are problems.
That's for a flat array, not something that tilts. So you're only going to get about 6hrs of full power output per day, assuming good weather. Now your 2MW drops to only 500kW of average power or lower.
And those panels are going to cost at least $0.50/watt or something like a million dollars, nevermind mounting, inverters, cabling, etc. Could easily triple the price there. Plus the sea is rough on everything. If the panels are rated for 30 years on land you should expect to get less than 10 years at sea, maybe less.
Finally the assumption that you can simply cover the top of a ship with no repercussions isn't necessarily true. For tankers and bulk carriers you might get away with it. But on container ships you'd have to figure out how to make the entire array fold away since these ships are top loaded and unloaded. https://thumbs.dreamstime.com/z/container-cargo-cranes-unloa...
The idea makes sense if you don't know the magnitudes of things. But once you do it starts to look less practical.
and then there is this https://en.m.wikipedia.org/wiki/Blackbird_(land_yacht)#:~:te...
Also I know there were some experiments with electrostatic or bubbles on the hulls of these huge ships... https://www.google.com/amp/s/www.marineinsight.com/green-shi...
Also what about huge autonomous kites...? https://en.m.wikipedia.org/wiki/SkySails I mean surely such systems are complicated but with today's sensors and autonomous systems i'm sure people could come up with something that is better than burning 3rd grade fuel to bring us gadgets and junkets...
I wonder if maybe there are good options for powering electric ships mid-journey. For instance, suppose you have a container ship with enough battery capacity to operate for one day. On its usual route, there is a power line running along the ocean floor, and buoys at regular intervals with cables that bring the power up to the surface. Once a day, the ship stops at one of these buoys and charges its batteries for an hour, then continues on its way.
Also, as oil is consumed, the ship gets lighter and easier to push. Not so with batteries.
Making it more efficient is the only way forward.