We use the First Law of Thermodynamics,
In scenario 1, $dQ=0$ since the system is insulated, so $dU=W$, where $W$ is defined as the work done on the system and $dU$ is the corresponding change in internal energy.
In scenario 2, the system allows the passage of some heat, so $dQ$ is allowed to be nonzero (but still could be zero, i.e. for an adiabatic process). Here's where things get complicated. We can't actually say anything about the sign or magnitude of $dQ$ in general, since that depends on the particular way that work is done on the system (for an ideal gas, this refers to the particular path of the process in $PV$-space). As such, we cannot determine the value or sign of $dU$ in general.
However, if the system is an ideal gas or incompressible solid, and if we know the system's temperature is constant, then, since internal energy is proportional to temperature, $dU=0$ in this case.