The most common shadow technique “shadow mapping” does not work with environmental lighting since there is no position in 3D space from where you can generate a shadow map. That is however possible with punctual lights like spot, directional and point lights.
I imagine this would work with a path-tracer like Blender’s Cycles renderer. I’m not sure how it could be done in a realtime rasterizer like Blender’s Eevee, or THREE.WebGLRenderer.
Yeah, a ray tracing engine could do this (at a cost, maybe not realtime, but these days we might be surprised). Three’s rendering is not a ray tracing one, but rasterizing (calculating light/color per pixel based on input parameters without knowledge of all objects light may have come from, which is unlike a ray tracer that follows light rays through a scene through objects it may have bounced off of or passed through by the time it exits the current pixel to the camera which could potentially involve many more calculations).