Depending on the specific agent you get, the process will vary. They don’t exactly train their employees to deal with this. Print and bring a physical copy of the laws, rules, regulation, processes, etc. from tsa, airline, etc websites. They will likely first say that you can’t fly with them or something stupid. Show them their own regulations and local laws that you can. Then they will want the key to inspect it in private. They are not supposed to do that. They need to inspect it in front of you. If they want to go to a private room with you that may be ok. Make sure the firearm case has a non-tsa lock and only you have control of the key at all times. This will piss of the agent who thinks you are not “respecting his authority”, so it will add a lot of time to your check-in. It’s 100% legal and they need to learn and practice the process. Small cases are usually packed in a larger suitcase - padlock on the case, tsa lock on the suitcase. Large rifle cases I always checked on their own. Sometimes the airline makes you pick these up in a special room, sometimes they go on the conveyor belt. Durable hard sided case with padlock hole like a Pelican are a must. Thin metal cases with their own key can easily be dented and pried open.
Eta: it may be a good idea to breakdown your rifle and pack it as 2 pieces in the case. That would help with showing that it’s not loaded.