US President Donald Trump has threatened to escalate military actions against Iran if attacks on commercial shipping in the Strait of Hormuz persist.