how to design a low pass filter for square waveform
There can be no generic answer to this question. Ideal square waveform includes harmonic frequencies up to infinity, so whatever low-pass filter you use, it will reduce the harmonics above the pass-band frequency. This is seen as "ringing" because the result is equivalent to adding those filtered harmonics to the ideal square waveform (precisely, the harmonics are subtracted, but it is just negated adding).

The level of harmonics decrease towards infinity according to sinc function:
If the base frequency of square wave is \$x\$, harmonics come to frequencies \$f=x+2Nx\$, where \$N\$ is integer \${1,2,3,...}\$, and the relative level of harmonics for each \$f\$ is  \$|\sin(\pi f/(2x))/(f/x)|\$ (the equation is just simplified from sinc function that is normalized so that level is 1 at \$x\$).
So, in practice, the level of harmonics after some frequency get insignificant and can be filtered out, but the frequency limit depends on the application, i.e. it depends on the allowed level of ringing and slew rate (Notice that also slew rate becomes the lower the lower is the frequency limit).
For example, if the square wave is clock signal, you might even manage with filter passband that equals to the clock frequency. Then basically you have only the base sine component left, but since you just need a periodic signal, that could be enough.
Other than that, there is no simple generic rule for the required filter passband.