Whether a creature is a friend or an enemy, you can’t willingly end your move in its space.
Emphasis mine.
Consider You and another creature (Zorb).
If you are forced to share a space with Zorb, it happens - no shunting in any directions unless something specifically tells you to.
So, if you fail a save against polymorph and are turned into a Large creature (and your new size overlaps with Zorb's space), then you are sharing a space with Zorb.
On your next turn (or Zorb's next turn, if it happens first), you must move to no longer be sharing a space (if it's possible).
That's RAW.
As far as how I would adjucate it: I would make use of the Squeezing rules.
Squeezing into a Smaller Space
A creature can squeeze through a space that is large enough for a creature one size smaller than it. Thus, a Large creature can squeeze through a passage that’s only 5 feet wide. While squeezing through a space, a creature must spend 1 extra foot for every foot it moves there, and it has disadvantage on attack rolls and Dexterity saving throws. Attack rolls against the creature have advantage while it’s in the smaller space
(thanks KorvinStarmast for the rules text)
I would mandate that you Squeeze so that your Large form only occupies a Medium creature's space (and no overlap happens in the first place), and that you cannot stop Squeezing until there is room for your entire form.
But that is not RAW, and is merely my opinion.