Is there a way to generate a grid of points as a texture? Something like this (without the box):
And/or is there a way to create my own texture node with Python? If there's API for that I guess I can also write my own procedure texture.
A wave texture will give you a gradient from black to white. Two of them rotated ninety degrees from each other gives you a grid. A colour ramp can then adjust the size of each square, which with the gradient becomes circular at smaller sizes.
Set the colour ramp to use constant interpolation to get a sharper edge. Adjust the position of the ramp stops to adjust the size of the spots. The mapping nodes and scale of the wave texture will adjust the overall placement.