In this experiment, C3N5 was synthesized by pyrolysis of 3-amino-1,2,4 triazole material, and then 1% Co-C3N5, 3% Co-C3N5, 5% Co-C3N5, 7% Co-C3N5, and 9% Co-C3N5 were synthesized by varying the mass ratio of cobalt chloride to C3N5 by stirring and ultrasonic shaking. SEM, XPS, and XRD tests were performed on the synthesized materials. The experimental results showed that Co atoms were successfully doped into C3N5. The electrocatalytic reduction experiments were performed to evaluate their NH3 yields and electrochemical properties. The results showed that the ammonia yield obtained by the electrolysis of the 9% Co-C3N5 catalyst as the working electrode in a mixed electrolytic solution of 0.1 mol/L KNO3 and 0.1 mol/L KOH for 1 h at a potential of −1.0 V vs. RHE was 0.633 ± 0.02 mmol∙h−1∙mgcat−1, and the Faraday efficiency was 65.98 ± 2.14%; under the same experimental conditions, the ammonia production rate and Faraday efficiency of the C3N5 catalyst were 0.049 mmol∙h−1∙mgcat−1 and 16.41%, respectively, and the ammonia production rate of the C3N5 catalyst was nearly 13-fold worse than the 9% Co-C3N5, which suggests that Co can improve the Faraday efficiency and ammonia yield of the electrocatalytic reduction of NO3−. This is due to the strong synergistic effect between the cobalt and C3N5 components, with C3N5 providing abundant and homogeneous sites for nitrogen coordination and the Co-N species present in the material being highly efficient active sites. The slight change in current density after five trials of 9% Co-C3N5 and the decrease in ammonia yield by about 12% in five repetitions of the experiment indicate that 9% Co-C3N5 can be recycled and work stably in electrocatalytic reactions and has good application prospects.