Probing UV-sensitive pathways for CN and HCN formation in protoplanetary disks with the Hubble Space Telescope