The process to protect JTAG with a password depends on whether the HSE firmware is used or not:
With HSE FW:
Set up the ADKP (Application Debug Key/Password).
Ensure that authentication method is configured as password mode or challenge-response mode.
Advance the lifecycle stage.
For more information, refer to section 2.6.1.4 (Debug) of the HSE_B Firmware Reference Manual, Rev. 2.4. Additionally, we provide examples in the HSE DemoApp (located in S32K3 Standard Software > Automotive SW - S32K3 - HSE Firmware) and in the S32K3 MCUs for General Purpose HSE Demo Examples.