An old project manager of mine flew with a gun once. It was entirely legal, because owning guns is legal, and flying is legal. It just had to be checked out and put away safely.
Flying with one in your carry-on is illegal for regular people. You can check one in your luggage but there's some special rules that sometimes the TSA and airline staff aren't familiar with (you must use a lock that is not TSA approved, you're not allowed to let TSA or airline staff borrow the key, stuff like that). The only time I traveled with a gun it was simpler (and cheaper!) to just mail it to myself.