Yes, a pilot can carry a gun. In the United States, pilots are allowed to carry firearms in the cockpit, as long as they have a permit to do so.