(edited/simplified the code after OP clarified that only z_l instances need to be colored for now)
You could achieve your objective by using LuaLaTeX and taking a preprocessor-based approach, as is done in the following example.

% !TeX program = lualatex
\documentclass[letterpaper]{article}
\usepackage{xcolor,mathtools}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}
\usepackage{luacode}
% The lua function 'color_zl' does the actual work
\begin{luacode}
function color_zl ( s )
s = string.gsub ( s , "z_l" , "\\textcolor{blue}{%0}" )
return s
end
\end{luacode}
% The lua function is assigned to 'process_input_buffer' callback:
\newcommand{\ZColorOn}{\directlua{luatexbase.add_to_callback(
"process_input_buffer", color_zl , "color_zl" )}}
\newcommand{\ZColorOff}{\directlua{luatexbase.remove_from_callback(
"process_input_buffer", "color_zl" )}}
\begin{document}
\ZColorOn % turn on automatic coloring of "z_l" terms
\[
0 = \frac{\partial}{\partial z_l}\bigl(
\norm[\big]{h(z_{l-1})\cdot w_l-z_l}
+ \lambda \norm[\big]{h(z_l)\cdot w_{l+1} - z_{l+1}} \bigr)
\]
\ZColorOff % turn off automatic coloring of "z_l" terms
\[
0 = \frac{\partial}{\partial z_l}\bigl(
\norm[\big]{h(z_{l-1})\cdot w_l-z_l}
+ \lambda \norm[\big]{h(z_l)\cdot w_{l+1} - z_{l+1}} \bigr)
\]
\end{document}
Addendum If you wanted to typeset in blue all instances of z with any subscript, not just z_l, you should modify the Lua function by enabling a couple of pattern-matching operations:
function color_zl ( s )
s = string.gsub ( s , "z_%b{}" , "\\textcolor{blue}{%0}" )
s = string.gsub ( s , "z_(%w)" , "\\textcolor{blue}{%0}" )
return s
end
The first pattern, %b{}, matches a matching pair of curly braces with any content. The second pattern, %w, matches a single alphanumeric character, e.g., l, 1, etc.
\def\z1{\ensuremath{\color{blue} z_1}}(untested) and use it as\z1or something like that. – TeXnician Feb 10 '17 at 10:17zblue without requiring any markup, quite a bit trickier (to the point that I wouldn't do it in a real document) to makez_lall go blue. (unless you want alllto go blue, which seems not to be the case asw_lis black). – David Carlisle Feb 10 '17 at 10:46$$in a LaTeX document to initiate and terminate display-math mode. See the postings Why is\[ … \]preferable to$$ … $$? and What are the differences between$$,\[,align,equationanddisplaymath? for more information on this topic. – Mico Feb 10 '17 at 11:06z_lor (b) all instances ofz_{...}should be colored in blue. – Mico Feb 10 '17 at 11:12z_l(doesn't have to get in to pattern matching) – Peter Feb 10 '17 at 11:51z_{l}orz^2_l? – Federico Poloni Feb 10 '17 at 14:44