The speed of sound is defined as $c^2 = \frac{\partial p}{\partial \rho}$, which for an ideal gas becomes $c^2 = \gamma \frac{p}{\rho}$.
For a real gas, the relationship to an ideal gas can be found through the compressibility factor $z$. This is a measure of how much a real gas deviates from an ideal gas. It shows up in the equations as:
$$ P = z \rho R T$$
You can work through the math on it (or follow along on this page), but essentially for a real gas, the speed of sound uses the compressibility factor $z$ and a factor $n$:
$$ n = \gamma \frac{z + T \partial z/\partial T \rvert_p}{z + T \partial z/\partial T\rvert_\rho} $$
such that:
$$c^2 = zn \frac{p}{\rho}$$
which can be related to the ideal gas speed of sound as:
$$c^2_{real} = z c^2_{ideal} \frac{z + T \partial z/\partial T \rvert_p}{z + T \partial z/\partial T\rvert_\rho} $$
For gases and conditions where intermolecular forces are unimportant, $z = 1$ and $\partial z/\partial T \approx 0$ and the ideal speed of sound is correct. This is true for a majority of gasses at ambient conditions. At very high pressures and/or low temperatures, real gas effects become important.