The temperature-induced orthorhombic to cubic phase transition in \(\hbox {Li}_2\hbox {C}_2\) is a prototypical example of a solid to solid phase transformation between an ordered phase, which is well described within the phonon theory, and a dynamically disordered phase with rotating molecules, for which the standard phonon theory is not applicable. The transformation in \(\hbox {Li}_2\hbox {C}_2\) happens from a phase with directionally ordered \(\hbox {C}_2\) dimers to a structure, where they are dynamically disordered. We provide a description of this transition by employing ab initio molecular dynamics (AIMD) based stress-strain thermodynamic integration on a deformation path that connects the ordered and dynamically disordered phases. The free energy difference between the two phases is obtained. The entropy that stabilizes the dynamically disordered cubic phase is captured by the behavior of the stress on the deformation path.