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]
If I'm not mistaken, the square wave case should in essence be the limiting case of the general case you get when looking at "trigonometric" functions which don't arise as the parametrisation of xˆ2 + yˆ2 = 1, but xˆn + yˆn = 1 for n > 2. It turns out that people have looked at that, and the study of those functions have been given the funny name "squigonometry". There's a Springer textbook out there.
Give it a try!
[1] https://www.sciencedirect.com/science/article/abs/pii/001600...