Statistical mechanics and thermodynamic systems can indeed be analyzed and formulated using variational and Lagrangian methods.