  We present an \textit{ab-initio} study of the quasi-2D layered perovskite
Sr$_3$Hf$_2$O$_7$ com\-pound, performed within the framework of the Density
Functional Theory and lattice dynamics analysis. At high temperatures, this
compound takes a \textit{I4/mmm} centrosym\-met\-ric structure (S.G. n. 139);
as the temperature is lowered, the symmetry is broken into other intermediate
polymorphs before reaching the ground state structure, which is the
\textit{Cmc2$_1$} ferroelectric phase (S.G. n. 36). One of these intermediate
polymorphs is the \textit{Ccce} structural phase (S.G. n. 68). Additionally, we
have probed the \textit{C2/c} system (S.G n. 15), which was obtained by
following the atomic displacements corresponding to the eigenvectors of the
imaginary frequency mode localized at the $\mathbf{\Gamma}$-point of the
\textit{Ccce} phase. By observing the enthalpies at low pressures, we found
that the \textit{Cmc2$_1$} phase is thermodynamically the most stable. Our
results show that the \textit{I4/mmm} and \textit{C2/c} phases never stabilize
in the 0-20 GPa range of pressure values. On the other hand, the \textit{Ccce}
phase becomes energetically more stable at around 17 GPa, surpassing the
\textit{Cmc2$_1$} structure. By considering the effect of entropy and the
constant-volume free energies, we observe that the \textit{Cmc2$_1$} polymorph
is energetically the most stable phase at low temperature; however, at 350 K
the \textit{Ccce} system becomes the most stable. By probing the
volume-dependent free energies at 19 GPa, we see that \textit{Ccce} is always
the most stable phase between the two structures and also throughout the
studied temperature range. When analyzing the phonon dispersion frequencies, we
conclude that the \textit{Ccce} system becomes dynamically stable only around
19-20 GPa, and that the \textit{Cmc2$_1$} phase, is metastable up to 30 GPa.
