Yes, you can use Top and Trim contact adhesive to glue foam together.
There are other contact adhesives that are intended for foam to foam applications. The one on the left is K-Grip, and the one on the right is called Kwik-Spray. Kwik-Spray comes in two different formulations, 225 which is a heavier viscosity and 220 which is not as heavy. I like the 220.
They can be sprayed from a regular spray gun, but I like to spray them from a Critter sprayer. The reason I like the Critter sprayer is that the container is just a Mason jar. If I want to change glue, all I have to do is change the Mason jar and put a lid and cap on the glue I'm not using.
The reason I like these foam to foam glues is they have a lot less fumes to them, they don't need to be perfectly dry to put the two pieces of foam together, and they aren't as aggressive as the top and trim adhesive but still hold foam together just as well. I use these glues to glue fabric to sew foam for that reason.
No one lives forever, the trick is creating something that will.