How to go about making a system to clip geometry when intersecting with another?

Hi everyone, in my game I wanted to do some fake really simple lighting so I have a sphere with a simple shader, it looks something like this:

It does the job and I actually kinda like how it looks, the problem is that the sphere (obviously) can go through the walls, kinda destroying the illusion, so I would like to know if there is a simple way to “clip” the lighting sphere so that it doesnt go through the wall

Thank you for your time and sorry for my english

Im also thinking that because the background will always be black I could somehow grab the screen color (before the light is rendered) and if the pixel is black or near black, dont render the light, but I dont know how to go about doing that either to be honest…