The US president has issued a stark warning to a US ally, in a sign of rising tensions over Strait of Hormuz.