Marco Rubio said US allies were open to helping escort ships through the Strait of Hormuz, which Iran has closed and threatened to charge fees for.
Reports say the US pressured France to rescind Ramaphosa’s invitation after Trump threatened to boycott the summit.
This year's summit in Canada did not go as planned, but leaders of the world's wealthiest nations still secured some wins.
The BBC's James Landale highlights the role of the US president at the summit as the conflict in the Middle East overshadowed the gathering.
President Donald Trump brandished a folder containing the UK-US trade deal, but the papers fell on the floor.
No 10 says G7 allies back the measures - but Donald Trump indicates the US will not impose more sanctions now.
The agreement signed at the G7 summit is limited but an achievement nonetheless, writes the BBC's political editor.
The US president will cut short his time at the meeting and return to DC, citing the conflict between Israel and Iran.