Does work equal heat in an isothermal process only for an ideal gas?

Is it only for an ideal gas that the work equals the negative of the heat in an isothermal process? Or, is this a general principle for all kinds of systems?

Or put differently, how do I know that for an ideal gas the internal energy only depends on the temperature?

As stated in other answers, the internal energy $U$ depends on other variables, e.g. volume, if internal interactions are not negligible.

On the other hand, there's a simple experiment which shows that for nearly ideal gases, such as air at standard conditions, $U$ is a function of only temperature $T$. (It is therefore assumed for ideal gases, that $U$ is exactly a function of $T$.)

In the experiment, we have an adiabatic container with a wall that divides it in two compartments: one side is filled with air at atmospheric pressure, and the other is a vacuum. Then, we remove the wall and let the gas expand. If we measure the temperature of the gas during the process, we observe the temperature practically stays constant.

Now let's look at the whole process. Since the gas is thermally insulated, it doesn't exchange heat with the surroundings: $$Q=0.$$ The work done on the gas during the process is zero, since there's no force that keeps the gas from expanding:$$W=0.$$ So, by the conservation of energy: $$\Delta U = Q+W=0.$$ The net result is a change in the volume occupied by the gas (with an inverse change in pressure), while $\Delta U =0$. So, we conclude internal energy is independent of the volume for ideal gases.

Is it only for an ideal gas that the work equals negative the heat in an isothermal process or is this general for all kinds of systems?

In an isothermal process, $T$ is unchanged. In an ideal gas, $U$ only depends on temperature, so $\delta U=0$. Since $\delta U=\delta W+\delta Q$, you have $\delta W=-\delta Q$.

This is not necessarily valid for non-ideal gases. For materials with interparticle interactions, the internal energy $U=\left<E\right>$ can depend on other parameters of the configuration state of the gas, such as $P$ or $\rho$. Part of the definition of an "ideal gas" is that the particles are non-interacting.

Or put differently, how do I know that for an ideal gas the internal energy only depends on the temperature?

A good quantum mechanical derivation of the heat capacity of a monatomic ideal gas can be found in Chapter 16 of Physical Chemistry 4th edition by Robert Silbey. I can post a synopsis of it here if you'd like.

The approach also extends to diatomics and polyatomics; in essence, the heat capacity of a substance in the absence of intermolecular interaction is determined by the available molecular degrees of freedom.

No it definitely depends on the Equation of state describing the system. You may check the third post in the link for a mathematical derivation below.

Internal energy according to the van der Waals equation