WASHINGTON—The Pentagon has upgraded and tested the largest bunker-buster bomb in the U.S. arsenal, senior U.S. officials said, readying a weapon that could destroy or disable Iran’s most heavily fortified nuclear facilities should a nuclear deal fall apart and the White House decide to take military action.

Even while the Obama administration was pursuing a diplomatic agreement with Iran to rein in its nuclear program, the Pentagon was readying the improvements to one of its most destructive conventional weapons, including...