Yes! It's possible. But the air circulation inside a smartphone is limited and newer phones are completely sealed for waterproofing, so there are still some doubts.
> How are CO2 sensors built?
Based on my very limited experience on playing with electronics, I would say...
1. Previously, many CO2 sensors use an electrochemical process, the chemical cell in the sensor reacts with air, and outputs an analog voltage proportional to the gas concentration. They are large, have a distinct cylindrical shape similar to a microphone module, needs manual calibration, and common in the industry. For example, have a look at the datasheet of MG811 sensor, which mentioned how the chemistry works: https://sandboxelectronics.com/files/SEN-000007/MG811.pdf
2. NDIR sensors is another traditional option. Inside a large rectangular blackbox, it has an infrared LED and some electronics. Basically, you shoot a beam of infrared light though the air and detect it on the other end, and correlate your measurement with the gas concentration. NDIR is reasonably accuracy, very popular in the industry, and can detect particulate air pollutants, and many types of gas. As an example, take a look at the MH-Z16 datasheet: https://sandboxelectronics.com/wp-content/uploads/2018/08/Z1...
3. It's now possible to build an all-in-one digital gas sensor on a piece of semiconductor chip! Examples include:
* CCS811, it has an on-die sensor that detects VOCs and CO2 concentration, and even includes a microcontroller that speaks I2C. And it only costs 5.76 USD each per 1000 pieces. Datasheet: https://cdn.sparkfun.com/assets/learn_tutorials/1/4/3/CCS811...
All the three CO2 sensors I've mentioned are available on sale from Adafruit and Sparkfun for anyone who's interested to experiment with.