Boolean a shape out of an object and place goop on the new faces. If you invert the normals of the cutter objects and enable the Material Transition Geometry Node after the boolean, you'll get a transition between two materials with goop in the middle. Otherwise, the Material Transition Geometry Node must be off. Some of the input fields in the geometry nodes have a tooltip if you hover over them.
The .blend file contains two scenes displaying both effects.
For the boolean meshes to intersect, you'd need to mesh boolean union them into a single object. For this to also work for the transition effect, perform this boolean inside geometry nodes, where you can flip the faces of the resulting mesh.
For more details, check out my tutorial: https://youtu.be/ivT7dG3i03Y
A blender file