Search for high-mass $\mathrm Z \gamma$ resonances in proton-proton collisions at $\sqrts=$ 8 and 13 TeV using jet substructure techniques