Well, he’s on a pirate ship and he’s… not a pirate.
Here’s something to know about pirates or anyone who spends lots of time alone in a small enclosed space: they know each other. In particular, pirates are rather loose and democratic organizations. They’ll know if they’re taking on new crew, and they’ll know who that crew is. If he’s found aboard their ship (and he will be), he won’t be able to pass himself off as one of them.
Criminals who run successful raiding operations aren’t stupid, especially those who’ve managed to keep at it for any length of time and are difficult to track. They live outside the law, they are outside its protections, and they know what the punishment for their capture will be. (Usually, it’s death.) This goes for every single member of the crew, not just the captain or their leader. Pirates generally get treated as stupid in vast swaths of media. They’re not. They’re smart. Many of the pirates during the Golden Age of Piracy were ex-navy of one sort or another. Many of the pirates making up this crew will be former sailors trained by a branch of the same military your MC comes from. They know what a military man looks like. Their survival is dependent on avoiding authority, and tackling those isolated targets they can successfully take. A criminal needs to be able to spot a policeman, including one in plainclothes. Their ability to continue operating depends on it.
So, how does this guy get captured?
He’s not a pirate, and hasn’t convinced them that he’s their new recruit. (At this point, he can’t. Too short on time. Too late. They’ll know who their new crew are.) He’s trapped in an enclosed space, aboard a ship, that is probably in the air if he able to stay hidden after they took off (as they’d almost certainly slit his throat before leaving if they found him). He has nowhere to go, no way to get off that doesn’t involve encountering enemy pirates who will recognize him as a stranger and an enemy.
He’s going to be taken captive. There’s one of him, and many of them. The only question left is how to get him out of the situation, instead of falling to his death by many thousands of feet when they chuck him overboard.
The real question for you is not: how is he taken captive? It’s: what reason do they have to keep him alive?
If he’s really lucky, he ditches the tracker before they find it on him and can make up a believable story. If he’s sort of lucky, they chuck the tracker overboard and lock him in the brig. If he’s super unlucky, then he’s going over the side and it’s “goodbye, MC”.
Stowing away is not an act with a lot of great career options ahead.
If you’re really having trouble coming up with ideas, I’d take a step back and go research pirates. You’re shortcomings here are based a lack of understanding for your MCs opponents. If you have a character getting caught, then the actor is the enemy. Those are the characters you need to focus on. It’s easy to assume that one character (the main character) is the driving force of all action, and because you (the writer) are most closely associated with them you see most of the situations from their perspective. However, this will catch you when you’re trying to write fight scenes or any kind of story action that relies on other parties to drive your story forward.
Spend some time with your villains. Figure out how the pirates function, how they work, what their command structure is (if they have one, lots of pirate ships were democratic with their captains voted in), and how they’re functioning. If you’re basing these pirates on the Golden Age of piracy, it might behoove you to look at history. The behavior of the pirates was often a direct response to the military/naval organizations of the time. The British Navy, for example, was well-known for being tyrannical and naval captains were given carte blanche over their crew. The Chain of Command was god, and their word was the ultimate law. It didn’t matter how mad, nightmarish, or suicidal the choice may be. If you ended up with a sadist as an officer, there were few appeals and you were at their literal mercy. The rules were strict. Many pirates were sailors fleeing that abusive lifestyle.
Take some time to figure out how your pirates function, how they live, what their ship looks like, etc. If you’ve gotten stuck, it’s usually because you’re focusing on the wrong characters. Spend some time with the ones who discover your MC and take him captive. That should get you back on track.