Do you think it would effect performance.
Probably NOT a good idea. They make stuff especially for that purpose (it's called "potting compound') but it usually ain't
cheap (at least for the good stuff) and it will add weight because it's not foam it's more like a plastic or rubber substance,
depending on what you buy.
Any other typical foam would likely not have the electrical properties to prevent adding conductive, capacitive, inductive,
or other properties which would more than likely mess up the electronics of the item being covered with it.
Another consideration is that even when using the stuff made for the purpose it can sometimes stress surface mounted components.
I usually just opt for either the "brush it on" or "spray it on' (preferred) conformal coatings to both waterproof the circuits AND strengthen
the physical connectivity of the surface mounted parts
Just a small dab of hot glue where the plug meets the base of the connector was what I meant earlier