Hmmm...how about this scenario?
Maeglin is with another member of the House of the Mole when he ventures outside the mountains and gets caught. This character can be introduced when Maeglin comes to Gondolin - perhaps he is the first elf to befriend him, and he leaves his own House to join Maeglin's new House. His character can be whatever we like - a grasping political climber weaseling his way in to being close to (potentially) the King's heir, or an older elf who feels badly for Maeglin and takes him under his wing to introduce him to Gondolin society, or one of Aredhel's guards who feels guilty for losing her all of those years ago and wants to make it up by serving her son, or a younger elf who looks up to this mysterious newcomer who has seen the world outside of Gondolin....whatever.
So, Maeglin gets a reputation for his mining expeditions, and one day decides to venture further afield. This elf could be his accomplice, egging him on, or the voice of reason saying 'we should go back...' but be unable to gainsay his lord. Again, whatever fits his character. It gives Maeglin someone to talk to about what he's doing, so that's always helpful. They go out, they get caught...and Sauron enters the picture. Now, in the original story, Maeglin is questioned first by an unnamed underling (why not Sauron?) before being taken to Morgoth when it's clear he's going to break. After he spills his knowledge, he is allowed to go back to Gondolin.
But seriously...why would Morgoth trust him? There's obviously a huge chance he'll think better of it and warn the elves of the impending attack. So...enter Sauron again. 'So sorry, but your friend is in no shape to return, [and we don't trust him]. But you can't return without him, or people will get suspicious. So, I'll just have to go in his stead.' Or it could be a surprise reveal to the audience after they're back in Gondolin that the elf sidekick has been replaced by Sauron. Sauron takes on the form of the friend, while the other elf is left in Morgoth's custody or killed. Maeglin returns to Gondolin with Sauron, who is in a position to watch Maeglin's every move.
...and have the opportunity to carry out his own betrayal, of the anti-balrog-charm variety. Impersonating an elf of the House of the Mole would give him the opportunity to work on weapons, after all.
We'll have to see if that fits all of the characters' motivations we'll need at this point in the story. I will point out that this mitigates Maeglin's actions *somewhat*, as he is more still-a-captive than a free agent with Sauron breathing down his neck like this. But knowing Maeglin, rather than earning any sympathy points for this, he will instead take it as an opportunity to lord over Sauron as his supposed underling in public. Emo goth characters are too busy feeling sorry for themselves for anyone else to feel sorry for them
That's the best way I can think of to smuggle Sauron into Gondolin without inventing a separate diversion story of how it happened. If we decide we need him there in person, that's a way of making it happen.