Using \hbox is not really recommended, because it can have unexpected effects.
\newcommand{\dottedline}[3][3ex]{%
\par % end the current paragraph (if necessary)
\nopagebreak % don't break a page here
\vspace{#1}% space before the signature
\noindent\makebox[#2]{\dotfill}% make the dotted line
\\* % go to a new line without any page break
\noindent#3% signature
\par % end the paragraph
}
Here's a complete example:
\documentclass{article}
\newcommand{\dottedline}[3][3ex]{%
\par % end the current paragraph (if necessary)
\nopagebreak % don't break a page here
\vspace{#1}% space before the signature
\noindent\makebox[#2]{\dotfill}% make the dotted line
\\* % go to a new line without any page break
\noindent#3% signature
\par % end the paragraph
\vspace{#1}% space below the signature
}
\begin{document}
Please sign here:
\dottedline{6cm}{A. U. Thor}
And your initials:
\dottedline[1ex]{3cm}{A. U. T.}
\end{document}
