Cosmic-ray-induced H$_2$ line emission: Astrochemical modeling and implications for JWST observations