Generate a random square texture from color input
You can get good results with a single Voronoi Texture

Set Randomness to 0
Plug the Color Output to your ColorRamp
Set ColorRamp to linear (since the edges are already defined)



Edit:
To keep the corner aligned: offset and scale the texture using The Mapping Node

Or offset the UV coordinates by 1 / ( 2 * scale)
Thanks to @Gorgious for providing the formula.