I am not aware of any foams made specifically for use with electrical wires. As far as I know, UL only tests such products as their use pertains to fire-rated assemblies.
UL has other standards that relate to flamability- and you can be sure none of the foams pass, as they all burn like rocket fuel. (As a historical note, it was the use of such foams, and their ignition by a plumber checking for drafts with a candle, that led to a nearly disasterous fire at the Browns' Ferry Nuclear Plant in the '70's....and which in turn spurred the development of the fire-resistant caulks we now use.)

The foams are mostly made of a urethane resin and catalyst, which reacts with water in the air to form a urethane foam. Crumbly as they seem, urethane is considered a syntheyic rubber. There really aren't any "solvents" as such involved. As urethane is itself used as electrical insulation (that red varnish on motor windings is also urethane), I don't see any risk here.

There is, of course, no reason you can't seal the hles the old-fashioned way, with joint compound, mortar, or plaster.