Try the ideal gas law
$$ p V = N k_B T \Leftrightarrow p = N k_B \frac{T}{V} $$
since $N$, $k_B$ and $T$ are constant, we have
$$ \Delta W = - N k_B T \int_{V_1}^{V_2} \frac{\textrm{d}V}{V} = - N k_B T \left( \ln(V_2) - \ln(V_1)\right) $$
You are right: if the gas you are studying is not in a container, it is difficult to attribute a volume to it.
The key here is to realize that on the scale of the atmosphere, temperature, pressure and density change - by a lot. So you can't think of "all of the atmosphere" as a single body of air with uniform properties - the properties change locally. As such, you want to express the behavior in terms of "local" properties only. This makes volume not a suitable candidate - but temperature, pressure and density are all locally defined, so ideal for describing such a system. As @t.c. points out n another answer, the formal name for such "locally defined" properties is "intensive", to contrast with "extensive" properties which apply to a system. Note that while the wiki entry says
An intensive property is a bulk property, meaning that it is a physical property of a system that does not depend on the system size or the amount of material in the system.
that doesn't mean it cannot change with location in the system - and indeed in the atmosphere they change a lot, which is why they are useful for describing the system.
update
Per David Hammen's suggestion, going from the ideal gas law formulation:
$$pV = nRT$$
to the formulation in terms of density, you replace $n$ with $\frac{m}{M}$, then divide both sides by $V$:
$$p = \frac{m}{V} \frac{R}{M} T$$
We recognize $\frac{m}{V}$ as the density $\rho$, and $\frac{R}{M}$ as the specific gas constant, sometimes written as $R^\ast$. This leads to
$$p = \rho R^\ast T$$
Now all parameters ($p, \rho, T$) are intensive quantities.
Best Answer
The Earth's atmosphere is mostly nitrogen and oxygen, both of whose behaviors are very close to ideal at the temperatures and pressures found in the atmosphere. Nitrogen, the dominant gas in the atmosphere, comes particularly close to exhibiting ideal behavior. Gaseous oxygen exhibits about a 3% departure at 20 atmospheres at standard temperature, with departures from ideal reducing more or less linearly at reduced pressures.
There is one component whose behavior is markedly non-ideal, and that is H2O. Water vapor is a trace gas, at most a few percent of the atmosphere (and that extreme occurs only in very humid tropical regions). Unless you are studying cloud physics, you can pretty much ignore the departures from the ideal gas approximation. The errors that result from assuming ideal behavior are generally less than one percent.
Non-ideal behavior becomes important if you want to model the atmospheres of Venus or the gas giants because of the higher pressures. For example, the CO2 that is by far the dominant component of Venus's atmosphere is a supercritical fluid at the surface of Venus. Departures from ideal behavior can be quite extreme in this regime.