They would be allowed to blockade neutral ships going to enemy ports (e.g. Israel) subject to a bunch of rules but that doesn't seem to be what they are doing.
I dont even think Iran is claiming this is a blockade. They are claiming its part of its territorial waters, and they are claiming that they dont recognize the UNCLOS which would give vessels transit rights (but at the same time they are claiming they recognize the part of UNCLOS that allows claiming 12 miles out as territorial waters). At least that is what i got from https://www.ejiltalk.org/the-legality-of-irans-closure-of-th...