Hydrogen cyanide in nitrogen-rich atmospheres of rocky exoplanets