"Code compliant" is pretty much a phantom here ... along the lines of "good workmanship."

Ductseal might work ... and is commonly used to seal pipe where condensatiohn may occur.

The packing and "chico" used in hazardous location stuff would also work .... IF you could get it in!

Otherwise, testing of various cables has shown that there is generally not an issue regarding spray foam damaging wire insulation. Maybe a squirt is in order.

BUT ... brilliant ideas aside .... what will happen when - not if, but when - the dam breaks? Do you want water to enter a quart at a time?

I'd say any patch is just that - a temporary measure until a more permanent fix can be made.