Plugging hole in hollow brick
The foam you suggest will work well for what you want to do. Do not over fill the cavity, leave room for expansion of the foam.

After it cures in a couple of hours, poke it in a little, maybe an inch, more would not hurt. Clean off the skin of foam that is left so the new cement bonds with the old. The act of pushing in to compress the foam should relieve a larger area behind the hole, so the cement mushrooms inside the hole.