The method won't work: if you have, say,
\section{Proof that $|x|\ge 0$}
the setting of \catcode`|=12 wouldn't take effect, because | would have already been tokenized.
The safest way is to say
\catcode`|=\active
\protected\def|{\ifmmode\expandafter\vert\else\expandafter\activebar\fi}
\def\activebar{...<whatever you want>...}
If you want to use Plain TeX without e-TeX extensions, the resulting command would be quite fragile, so use with care:
\def|{\relax\ifmmode\expandafter\vert\else\expandafter\activebar\fi}
(you find the reason for \relax in the TeXbook).
Let's try a Plain TeX document:
\input manmac
\everymath\expandafter{\the\everymath\catcode`|=12 }
\everydisplay\expandafter{\the\everydisplay\catcode`|=12 }
\beginsection $|x|$ is never negative.
|the $p$-norm| is
$$
\Vert x\Vert=\root p\of{|x_1|^p+\cdots+|x_n|^p}
$$
\bye
You get
! Argument of \\ has an extra }.
<inserted text>
\par
<to be read again>
}
because | has already been tokenized when the argument of \beginsection was being absorbed.
With
\input manmac
\let\manmacbar| % after manmac | is active
\protected\def|{%
\ifmmode
\expandafter\vert
\else
\expandafter\manmacbar
\fi
}
\beginsection $|x|$ is never negative.
|the $p$-norm| is
$$
\Vert x\Vert=\root p\of{|x_1|^p+\cdots+|x_n|^p}
$$
\bye
you get no error and the output is what's expected:

\appendtoksand\prependtoksfor such tasks. You can use\appendtoks b \to \everymathto achieve what you want. There must be something equivalent in LaTeX; if not, you can always copy the ConTeXt definitions. – Aditya Dec 25 '13 at 03:52\expandafter\everymath\expandafter{\the\everymath b}. Seems to work for me in everything but display mathmode. – A.Ellett Dec 25 '13 at 06:43\everydisplaytoken list.\everymathworks for non-display math mode. – lvaneesbeeck Dec 25 '13 at 12:03