We obtain a canonical form of a quadratic Hamiltonian for linear waves in a weakly inhomogeneous medium. This is achieved by using the WKB representation of wave packets. The canonical form of the Hamiltonian is obtained via the series of canonical Bogolyubov-type and near-identical transformations. Various examples of the application illustrating the main features of our approach are presented. The knowledge of the Hamiltonian structure for linear wave systems provides a basis for developing a theory of weakly nonlinear random waves in inhomogeneous media generalizing the theory of homogeneous wave turbulence.