How to seal a pipe pass-through in a basement wall
I would remove all the foam you can from the outside of the metal sleeve pipe, then coat the pipe with epoxy, then fill the rest of the material with any suitable concrete patching material.  You can easily find epoxies that bond to metal and concrete, and bond when wet - many will even cure underwater.  So you know it will bond to both the pipe and the patch material.
You could use all epoxy as long as it can be mixed thick enough to work on a vertical surface but if there's a lot of material to fill in, it might get expensive.
If you're concerned about the rust on the metal sleeve pipe, you could treat it with a rust stabilizer product.  These products turn rust to a black oxide and work OK, depending on how deep the rust goes.  I don't know if you could determine for sure the epoxy will bond to the black oxide although I suspect it would.  It may not be that important since the sleeve is not structural and the epoxy will hold things together to some extent.
Gorilla glue or other polyurethane glue is popular (great, great marketing) and performs pretty well for its intended uses but it's one of the most overrated products around.  It's not as versatile as people want it to be.  It is pretty close to expanding foam, in fact it foams up to fill gaps.  I would not try using it for anything here.