Can bad posture with pectus excavatum affect lung capacity?

Yes. In severe cases mostly from displacement of the heart. Most of the cases minimal reduction in lung capacity.