Obviously this only works on domestic flights but the airline will not lose your luggage if they know they are dealing with a legally declared gun. If they do, they get sued by the ATF. Your luggage will be given first priority if you just throw a shitty cheap gun from Walmart in there.
I know photographers who put a 300$ glockoff in their camera cases. Instead of the tsa doing god knows what a tsa agent opens the case in your presence, confirms that there's a gun in it, then you lock it and send it on it's way. Less chance of the tsa stealing all your shit. Not fool proof, though.