A: This question mostly arises in conjunction with formaldehyde in foam insulations. Formaldehyde is not used in making cellulose insulation which is made from shredded newspaper, fiberglass which is made from fibers of melted glass or rockwool which is made from fibers of melted rock.
Strictly speaking spray foam is not toxic. But, if your house catches fire, it does burn with a thick black smoke that can be toxic and this is one reason I avoid it if I can and use fiberglass or rock wool (neither of which can burn) instead.
Also, the gas that is used to make the bubbles in spray foam is usually a gas called an HFC (or hydrofluorocarbon) that, although, strictly not toxic itself, is 1,000 stronger than CO2 in causing global warming, so it is, in that sense, toxic.