Although this plan itself looks very childish, I couldn’t really figure out why armies -especially those consisting of mercenaries- couldn’t/didn’t try to infiltrate into medieval cities and capture them from the inside. It makes sense to think that cities weren’t that big and such entrances would arise suspicion, and armies were not disciplined enough to perform such activities. Yet, I’m more concerned about the defence mechanisms against that and whether an infiltration was even dared back then.
The threat of infiltration is quite literally "the oldest trick in the book" -- having been described in Homer's Iliad. It's an idea which people have known about since the Bronze Age, tried on occasion, and on some occasions it actually worked, but also met with failure and was hard to execute.
It’s a story people love to tell - the equivalent of a trick play in football — so for example we have the seizure of Rohtas Fort in India by the wily Sher Shah, who in 1538 asked the ruler of the fort to stand guardian over his many concubines— who were delivered in closed palanquins. The Rajah got a surprise when those “concubines” turned out to be soldiers — and this story is much told. Did it actually happen that way? No way to know, but safe to say that this fort was taken by one kind of treachery or another (my bet would be that this story was more an excuse for the Raja or someone else who’d betrayed the fortress than an actual concubine surprise)
Speaking very generally -- and that's the only way we can speak, because "medieval cities" is a category that covers so many places and times-- there were very few true cities in medieval Europe, and the ones that were, were guarded and their guards suspicious of strangers.
Soldiers would have been recognized as such very quickly-- typically foreigners and men in the business of soldiering would have been distinctive. Today we're quite accepting of the notion of "a random guy"-- that wasn't how people were seen in earlier times, when "who you are, where you're from, what you do, what Lord you serve" -- those personal details _are_ your social identity.
With that said, we have quite a few examples of "capturing a city by stealth", and Machiavelli discusses it explicitly in his "Discourses on Livy" -- but he does so to say that such stratagems "rarely succeed", and enumerates the many difficulties. While he's evaluating Roman history, he's doing so with an eye to contemporary strategy, that is, he's trying to draw lessons for his time.
The Chronicle of the Tocco, a recently discovered work describing the rise of Carlo I in late medieval Greece, mentions the seizure of towns and forts by stealth on quite a few occasions, Dragamesto, Varnakas and Aetos are specifically mentioned. Carlo I's preferred mode of attack was to identify an undefended stretch of wall and scale it with ladders at night. But the Chronicle records trickery used by defenders as well-- an attacking force lead by Yakub Spata was mislead into thinking that the city of Vompliana was poorly defended and that its inhabitants would welcome a them . . . it was a trap and the infiltrators were captured and Yakub killed when they tried to enter at night.
There are many other cities where we have mention that they were lost through betrayal by some inside, not generally infiltrators but rather disaffected citizens. Antioch seems to have changed hands several times in that way.
So we have record of it being tried, a record of it succeeding on occasion, and a record of it being foiled. In general it doesn't seem to have been an easy strategy to carry out.
See:
Kyriakidis, Savvas. “The Wars and the Army of the Duke of Cephalonia Carlo I Tocco (c. 1375–1429).” Journal of Medieval Military History: Volume XI, edited by CLIFFORD J. ROGERS et al., vol. 11, Boydell and Brewer, 2013, pp. 167–182.
Machiavelli: "Discourses on Livy", especially Chapter 32 "How dangerous it is to believe Exiles" and Chapter 33 "In How many ways the Romans took towns"