An object at L2 absolutely could avoid the sun and stay in Earth's shadow. It would be problematical for this spacecraft, which is powered by a solar array.
> This [L2] orbit (which takes Webb about 6 months to complete once) keeps the telescope out of the shadows of both the Earth and Moon.
>What is special about this orbit is that it lets the telescope stay in line with the Earth as it moves around the Sun.
and
> Webb's position out at L2 also makes it easy for us to talk to it. Since it will always be at the same location relative to Earth-in the midnight sky about 1.5 million km away - we can have continuous communications with it as the Earth rotates through the Deep Space Network (DSN)
https://en.wikipedia.org/wiki/Umbra,_penumbra_and_antumbra
https://astronomy.stackexchange.com/questions/13585/does-ear...