Naval blockades of enemy ports during war are legal, that is what USA and Israel argue they are doing. That is not what Iran is doing, they are blocking fully neutral ships from going in other countries waterways.
US at war? We are past the 60 days for a military operation. From US law perspective, it’s illegal. From the constitutional perspective only congress can declare war which they haven’t.
International law only applies when you ratify a treaty so it becomes domestic law. Thats how treaties work, they actually laws of the country hence the term ratification into domestic law. Why US doesn't violate international law on land mines and cluster bombs. US never signed that treaty.
And Iran is blocking a strategic chokepoint during a war of defense, pressuring their enemies due to the war being illegal and unprovoked. See how easy it is to argue?