Honestly – it should be legal.
I once had to deal with someone who resigned with a 2 month notice period but literally showed up to work for less than 10 working day in that duration. I Ended up having to figure everything out on my own when having to take over his responsibilities and made my life hell.
Idiots like that are the reason companies also tend to be strict during notice periods. My company was too lax to him; I wish it wasn’t.
If you’re taking a day or 2 here and there – sure. But passing on responsibilities shown be bare minimum.