What is the risk of flying with a collapsed lung?

Speak with physician. As noted, air trapped outside your lung but inside your chest can expand with increasing altitude. This can potentially be rapidly fatal. Your thoracic surgeon should provide guidance to safe and appropriate activities.
Death. If you have air trapped outside your lung but inside your chest ( as you will see in a collapsed lung) when you ascend to altitude that air will expand and press on surrounding lung. Depending on size and your anatomy this can cause a variety of problems right up to death. Your pulmonologist can tell you when it is safe to fly.