A Rewriting Coherence Theorem With Applications in Homotopy Type Theory