There are kits available which are two-part foam. Mixes in the spray nozzle and springs to life. That is what the factory sends me to refoam a tub after any repair or rat damage.
It isn't cheap! I would not be surprised to find that it is available from other sources for less - check it out. The factory part number for a small kit is 70293, does about two or three cubic feet.
There is a much larger kit available -
part number 70869 -which does a huge amount of foam. They list it as eight cubic feet, but I have gotten much more than that out of it.
Be careful with any foam product you use: it can get on your glasses and ruin them, the fumes are bad to breathe, and it MUST be used in warm temperatures only.
HTH