Make a new image, 10x10 pixels, you can make it bigger or smaller if you want

Right click on the brush tool, and select the pencil tool, use the smalles pencil size

Zoom in as far as you can, to make it easier and make an L shape. Then select the whole image(Ctrl+A)

Now go to Edit->Define Pattern, the name doesnt really matter

Open the image you want to add the grid to, and click on your paint bucket tool(if you dont have a paint bucket tool, click on the gradient tool) Now at the top select "pattern"

Now select the pattern you just made

Now, on the image you want to add the grid to, make a new layer and simply click anywhere on the canvas to fill in the grid