I'm aware of stories of people who've had their flights unexpectedly grounded in New York (, New York) so they just abandoned their checked pistol and refused to collect it. I'd imagine something similar. If you never take possession, it becomes harder to charge and convict someone for possession.
But wouldn't they know whose bag it was anyway? And there's cameras everywhere so it wouldn't help if you e.g. removed the bag tags or discarded the contents somewhere else in the airport.
Same thing that happens whenever your flight gets diverted to South Korea and you have condoms, or Indonesia and you have legal weed, or to Australia and you have a pineapple.
Which is that it depends on the mood of the person in charge. Either you get to keep it, or it's confiscated and destroyed, or you go to jail, or you go to a firing squad.
We can guess which is more likely in each country. Indonesia almost always executes people found with drugs. Australia would probably just destroy your pineapple. India, being authoritarian but not completely insane, my guess is they'd take it and fine you.
Welcome to the world. If someone wants to shoot you, they can just do that. If that someone is a government, they won't suffer any consequences. There have been flights deliberately diverted by the country they were traveling over because they didn't like one of the people onboard, and that person was arrested by that country upon landing. I think the USA does this most frequently but it's also happened in CIS countries and Asian countries.
I was probably thinking of Romania a century ago. But you can imagine for every normal thing there is probably a country where it is banned. And South Korea is a country where some things are banned that you wouldn't expect.
When you're standing at the customs office entering a country, your lawyers are far far FAR away and the people talking to you won't care about them even a little bit.
Whatever will happen with you lawyering and fighting the border officers, will happen after you've been detained.