If the US had lost more carriers at Midway and had not sunk the majority of the Japanese carriers, it would have been a huge setback for the US Navy.
Yes the US would still have excellent chances to win the war, as long as the will to keep waging it held out. The Japanese had insufficient ability for long-range offensive action to actually be trying to do more than get a favorable peace treaty out of the USA, and the US had ridiculous capacity to build more ships etc.
So the actual Japanese strategic goal was to hurt the US so much that we sued for peace with favorable terms, and the plan to do that was to win a major naval victory, which was the main reason to go after Midway – to force a major engagement and win it.
What it would actually have taken to get the US to sue for peace, I don’t know, but I think the odds were pretty long against that happening even with some major naval defeats. Maybe a shocking loss of huge amounts of men if a naval defeat led to many losses from sunken troop transports, or something.
But many major naval defeats were pretty unlikely, I would say. So I think the most likely result in any case was a US victory. If the US had lost at Midway, it would have been delayed, however.