Foam interrupts the "oxygen" side of the heat-fuel-oxygen fire triangle. Unfortunately, lithium-ion batteries make their own oxygen when heated, so it doesn't help to smother them.
The advice is to use copious amounts of water to cool the batteries, removing the "heat" leg of the triangle. This works but requires extended periods of cooling support due to the possibility of internal shorts re-supplying the heat, and starting the process again.