The reason why the Fourier basis works so well is because it forms an orthogonal basis for all smooth real-valued functions. We'd need a similar way to define square waves which form an orthogonal basis. Found one paper doing that: A REVIEW OF ORTHOGONAL SQUARE-WAVE FUNCTIONS
AND THEIR APPLICATION TO LINEAR NETWORKS [1]
Give it a try!
[1] https://www.sciencedirect.com/science/article/abs/pii/001600...