Adapting from code in this answer
\documentclass[12pt]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{fancyvrb,xcolor}
\usepackage{lipsum} % just for the example
\newsavebox{\FVerbBox}
\newenvironment{FVerbatim}
{\VerbatimEnvironment
\begin{center}
\begin{lrbox}{\FVerbBox}
\begin{minipage}{5.8in}
\begin{Verbatim}}
{\end{Verbatim}
\end{minipage}
\end{lrbox}
\fcolorbox{blue!30}{gray!7}{\usebox{\FVerbBox}}
\end{center}}
\begin{document}
\lipsum*[2]
\begin{FVerbatim}[fontsize=\small]
Text.
With { \ strange /##& characters
\end{FVerbatim}
\lipsum[3]
\end{document}
Here's a version with additional vertical spaces. The interaction with Verbatim
makes it somewhat difficult to guess at the right proportions, just experiment.
\documentclass[12pt]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{fancyvrb,xcolor}
\usepackage{lipsum} % just for the example
\newsavebox{\FVerbBox}
\newenvironment{FVerbatim}
{\VerbatimEnvironment
\begin{center}
\vspace{1ex} % additional space above the frame
\begin{lrbox}{\FVerbBox}
\begin{minipage}{5.8in}
\vspace*{4ex} % additional space before the verbatim material
\begin{Verbatim}}
{\end{Verbatim}
\vspace{1ex} % additional space after the verbatim material
\end{minipage}
\end{lrbox}
\fcolorbox{blue!30}{gray!7}{\usebox{\FVerbBox}}
\vspace{1ex} % additional space after the frame
\end{center}}
\begin{document}
\lipsum*[2]
\begin{FVerbatim}[fontsize=\small]
Text.
With { \ strange /##& characters
\end{FVerbatim}
\lipsum[3]
\end{document}
For fancier boxes, you can have a look at tcolorbox
fancyvrb
is what you're looking for. Possibly you can adapt the code here: tex.stackexchange.com/a/182489/4427