You should remove the comment if you want that enabled if I am not mistaken.
So the code would look like
define MAX_HARDWARE_ENDSTOP_Z true (NO # sign in front of it)
So the code would look like
define MAX_HARDWARE_ENDSTOP_Z true (NO # sign in front of it)