It does not. It's linear in other cases too. Square wave can be approximated by pushing sinusoidal function to some transformation $g(f)$, like : $$y(t)=\tanh\left(k\sin\left(\omega t\right)\right) \tag 1$$

Triangle wave similarly can be achieved by filtering sinusoidal by:
$$ y(t) = \arcsin(\sin(\omega t)) \tag 2 $$

Nor hiperbolic tangent, neither $\sin^{-1}$ are periodic functions, only $\sin()$ is, so in both cases $E= \hbar \omega$ linear relationship also holds as long as custom wave can be represented by sinusoidal function $g(f)$ transformations.

In addition I believe that almost all "convoluted" signals can be decomposed into series of sinusoidal functions by Fourier transform. 

Also sometimes (usually ?), the REAL signal used in telecommunications and other areas, does not have well-defined "own frequency". Lets look at this type of signal :

[![enter image description here][1]][1]




  [1]: https://i.sstatic.net/RSI1P.png