Quantum optical analysis of high-order harmonic generation in H$_2^+$ molecular ions