I can give you the project files if you want.
But in short, I use two additional viewports. The first one is just a black screen, where I draw white circles on whenever a pellet "pops". The circles radius is tweened, so it isn't revealed all at once. The second viewport just contains a copy of the dark tilemap with a different tileset and the background. I then use the texture of the second viewport as a sprite, which I put between the player character and the dark map . The texture of the first viewport with the white circles is then applied to the second viewport as a mask with a shader, showing only pixels where the texture of the first viewport is white.
It's really complicated and inefficient, though. There are probably a dozen easier and less resource hungry methods to do something like this.