Yes, a passenger can take a picture in the cockpit, but it's not as common as you might think. If you're an influencer with a large following, you may be able to get away with it, but it's still not something that's generally done. Why do airlines pilots keep the cockpit door open during boarding operations?