Level bombing in general proved to be terrible at attacking moving ships, which makes the rare success all the more memorable.
There was one. One lone warship hit and sunk while at sea by B-17s in a level bombing role.
During the Battle of the Eastern Solomons in August of 1942, a Japanese transport, the Kinryu Maru, had been crippled and the destroyer Mutsuki had been assigned to assist her. While alongside, eight B-17s appeared and dropped upon the two Japanese vessels. By this time in the war it was common knowledge that the big bombers were unlikely to hit anything from high altitude, so the Mutsuki did nothing to get out of the way... she wasn't going to be hit. That's just the way it worked.
Except this time, it didn't work that way. At least one bomb (and possibly three) hit the Mutsuki, landing right in her engineering section. Some 40 or so men were killed, and the survivors were taken aboard another destroyer before she sunk.
The Germans actually had quite a bit of success in the level-bombing mission vs ships once they created their guided weapons, the "Fritz X" and Hs293. Both proved remarkably accurate.
There were more than a few instances where B-17s attacked, and destroyed, Axis shipping in the Mediterranean sea in 1943.
The 301st Bomb Group earned a Distinguished Unit Citation for actions on 6 April 1943 when they bombed an enemy convoy near Bizerte, Tunisia. Despite intense AA fire, they dropped their load on the ships, resulting in the largest ship's detonation (likely as a result of the cargo it was carrying,) along with damage caused to other ships in the same convoy.
http://32ndbombsquadron.com/32ndawrd.html
Following up on the 10th of April, the 301st landed several direct hits on the Italian cruiser TRIESTE near La Maddalena, Sardinia, resulting in it's destruction.
https://i.imgur.com/HQMdTcp.jpg