> What is the mathematical statement for the first law of
> thermodynamics, accounting for kinetic energy, potential energy,
> internal energy, work, heat and most importantly taking into
> consideration the work-energy theorem?

The general form of the first law for an closed system (a system where no mass crosses the system boundary) is

$$\Delta E_{tot}=\Delta U+\Delta KE +\Delta PE= Q-W$$

Where the terms are defined in the figure below that illustrates a general closed system. 

The work $W$ term includes the work that crosses the system boundary (that associated with the change in internal energy) as well as the external work on the system as a whole. It is the net external work done on the system as whole where the work energy theorem applies, i.e.,


$$W_{net-external}=\Delta KE$$

> Also, is $∆U=∆Q-∆W$ only valid for systems whose center of mass is at
> rest in an inertial frame, or is it also valid for other systems?

It is valid whether or not the center of mass is at rest or moving in an inertial frame, because $\Delta U$ only applies to the change in internal kinetic and potential energy of the system at the atomic/molecular level. 

For example, the temperature of your cup of coffee, which is a measure of its internal kinetic energy, doesn't change if you drink it while standing on the road, or in your car traveling at a constant velocity with respect to the road. But the kinetic energy of the cup of coffee as a whole is zero with respect to the road when you are standing on the road, and 1/2$mv^2$ with respect to the road while driving the car.

Hope this helps.


[![enter image description here][1]][1]


  [1]: https://i.sstatic.net/7hZrm.jpg