You want to map the interval $(0,24)$ to the interval $(0,2\pi)$ - a full cycle -; the function to do so is
$$2\pi \frac{\mathrm{hour}}{24}$$
You then need two terms in your linear model (recall that an equivalent non-linear parametrization uses phase & amplitude):
$$\beta_1 \sin\left(2\pi\frac{\mathrm{hour}}{24}\right) + \beta_2 \cos\left(2\pi \frac{\mathrm{hour}}{24}\right)$$
Noon & midnight aren't constrained to result in equal predictor values because the phase is estimated from your data. Noon might be at the peak and midnight at the trough of the wave.
(And And you can continue with harmonics in an analogous way to higher-order polynomial terms: $\ldots +\beta_3 \sin\left(2\times 2\pi\frac{\mathrm{hour}}{24}\right) + \beta_4 \cos\left(2\times 2\pi \frac{\mathrm{hour}}{24}\right)+\ldots$)$$\ldots +\beta_3 \sin\left(2\times 2\pi\frac{\mathrm{hour}}{24}\right) + \beta_4 \cos\left(2\times 2\pi \frac{\mathrm{hour}}{24}\right)+\ldots$$