Not if they’re submerged. Electromagnetic fields are greatly attenuated by water. This is why subs must either come to the surface to use radio or rely on VLF comms which penetrate the water but provide only very low bandwidth.
Google “EMP Report” to read more about the effects of EMP, don’t rely on 2nd hand sources. It’s all out there.
The Diesel motors that run the propulsion system would not be affected by EMP, even if the sub were on the surface. But the sub, at depth, is powered by battery-driven electric propulsion, which if on the surface, WOULD be vulnerable to EMP, as there are all kinds of load-switching electronics, to shift between the charging of the batteries, and the draw-down of energy stored. Also, virtually all the guidance wiring and control surfaces would be knocked askew.
Could they cripple back to port? Maybe, but as a combat vessel, they would be virtually useless. And there might not be a serviceable port for them to repair to.