The attack on Thursday highlighted the fragility of a preliminary deal to end the Iran war.
Two US officials had told Reuters on condition of anonymity that Iran had fired on the ship.
Trump said an Iranian drone had hit the upper deck.
"Damage was done, but the Ship was able to proceed on its way," he wrote on Truth Social.
"We knocked down three other Drones. Obviously, this is a foolish violation of our Ceasefire Agreement."
On Thursday, news emerged of an attack on a cargo ship in the Strait of Hormuz.
The UK Maritime Trade Operations reported that an "unknown projectile" had damaged the ship's bridge.
Iran had earlier expressed anger at what it said was an "interventionist, irresponsible and provocative" statement by the United States and six Gulf states that rejected its assertion that it could charge tolls on vessels transiting the strait.
"Safe passage through the Strait of Hormuz cannot be guaranteed under ambiguous arrangements, parallel routes or decision-making that does not take Iran's role as a coastal state into account," Iranian Deputy Foreign Minister Kazem Gharibabadi said on X.
Bloomberg News said Oman, which lies on the opposite side of the strait from Iran, had told allies ships going through Hormuz may have to pay.
Reuters could not immediately confirm the report.
The foreign minister of fellow Gulf state the United Arab Emirates held his first announced phone call with his Iranian counterpart since the start of the conflict, UAE state news agency WAM said, underlining efforts to overcome tensions.
It said Sheikh Abdullah bin Zayed underlined the need to ensure freedom of navigation through the strait, where shipping had picked up pace before a new slowdown after the ship attack.
Iranian state TV said three foreign tankers attempting what it called an "unauthorised passage" of the strait were turned back after a warning from the Islamic Revolutionary Guard Corps.
It gave no further details.
Asked about the matter, a US official said: "We are aware of these reports and looking into them. President Trump has been clear that Iran cannot subvert the free flow of traffic in the strait."
Saudi Aramco resumed crude loadings on Friday at its Ras Tanura terminal in the Gulf, the world's biggest oil port, after a nearly four-month halt, shipping data showed.
Fertiliser shipments through the strait have also picked up, helping to assuage concerns about a spike in global food prices because of the waterway's prolonged closure.
with DPA