The Pentagon has confirmed that, as part of its operation with Israel, a US submarine sank an Iranian warship in the Indian Ocean.