And this little thingy makes a lot of M2 MacBook Airs fail.
In older versions of macOS you can simply try two things:
* Press Esc in locking screen, or * Press "Sleep" from the menu bar icon and then press Esc immediately
If the machine crashes/reboots, the sensor is bad and it needs to be replaced. Apple Store replaces the whole display assembly.
15 inch and M3/M4 models are not affected, AFAIK.