A New Equation for a Scalar Field from Thermodynamics First Law and Its Cosmological Implications