Think something like ardupilot but for manned aircraft.
Short answer: technically and legally yes, a free open source autopilot could be certified. But I think it is unlikely to happen anytime soon.
Long answer: Aircraft software certification is governed by DO-178C. There is nothing in there that says anything about whether the source is open vs closed, or free vs non-free. What it does lay down is a lot of very rigorous requirements for proving that the software does what it says it is going to do.
For example, for something like an autopilot, an independent testing/validation would typically be required. That means the person who writes/codes the software and the person who tests the software have to be different people. i.e. you must have a fresh set of eyes looking at it. Further that testing will have be very extensive, covering every possible scenario your autopilot could encounter. You might have to mock up an entire fake airplane, with simulated sensors and simulated actuators, and feed the autopilot simulated data and see if the actuators move like they are supposed to.
You also need to provide a massive amount of very careful documentation about all parts of your software process. E.g. the software requirements need to documented, and then you need to be able to show every step of the way on how each specific requirement gets translated into the final machine code.
An free open source project certainly could meet all of these requirements. However, they end up being very time consuming and expensive. You need an army of software engineers working all day every day for years to meet some of these requirements. FOSS project typically do not have the level of manpower that is required to meet these requirements.
There is no practical way for Free Open Source Software to be used in any FAA certified equipment. This approach to software development encourages users to modify and contribute code, so as to benefit the entire community. Much of the motivation is to see the code improved and put into use.
FAA certification requires such extensive testing and documentation that revisions do not occur except to correct a serious flaw, and this usually means removing the hardware and returning it to the manufacturer. New functionality might require a new generation product. It is not likely that a five or ten year wait for new features would be attractive to FOSS developers.