Some (not all) airports have fire trucks equipped with High Reach Extendable Turrets (HRET) with penetrating lances fitted. These can pierce the fuselage and inject foam into the affected area.
A quick Google doesn't give too much detail but we covered the topic in some depth in liaison visits/meetings with the ARFF when I was based at Stansted.