I think this may not be possible in the environment verbatim- at least what Lamport says in LaTeX (first paragraph on page 64). However, you can do this with the command \verb: it \verb+\end{verbatim}+works just fine (and in fact you can use any character instead +, as long as you match them).
However, the package listingsis smart enough to have an escape character. For instance,
\begin{lstlisting}[escapechar=+]
+\verb!\end{lstlisting}!+
\end{lstlisting}
does exactly what you are looking for. (Again, choose a different character than +if you are already using this for something else.)
source
share