If I rember well (I have only visited one once) the cockpit of an airliner is small and full on instruments, levers, switches, etc...

I'm not sure even a properly trained person can move enough to do something usefull with a gun... while piloting a plane...

I prefer undercover armed air marshall(s) or some of the flight attendant properly trained and armed.