You need \dimexpr to have the minipage evaluate the expression, and then \dimexpr\textwidth-2\parindent.
The rule was not centered because you had \centering active and \hfil\rule{}{}\hfil, but TeX discards glue (which includes \hfil) at the end of a line, so the last \hfil was removed. And with \centering you have \leftskip and \rightskip doing \hfil, so you had 2 \hfil to the left and one to the right, thus the misalignment.
The simplest case to make that into a command is with \newcommand\myquote[2]. If you want additional settings to this quote environment you might need to add an optional argument and a keyval parser to set some options.
I changed the page layout for the example, but you can change back.

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[
a6paper,
showframe,
]{geometry}
\newcommand\myquote[2]{%
\par
\begin{minipage}{\dimexpr\textwidth-2\parindent\relax}
#1
\par\vspace{1ex}
\noindent
\hspace*{0.25\textwidth}%
\rule{0.5\textwidth}{.4pt}
\par\vspace{1ex}
\centering
\textsc{#2}\par
\end{minipage}
\par}
\begin{document}
\myquote{
When asked what it was like to set about proving something, the mathematician
likened proving a theorem to seeing the peak of a mountain and trying to climb
to the top. One establishes a base camp and begins scaling the mountain's sheer
face, encountering obstacles at every turn, often retracing one's steps and
struggling every foot of the journey. Finally when the top is reached, one
stands examining the peak, taking in the view of the surrounding countryside
and then noting the automobile road up the other side!
}{Robert Kleinhenz}
\end{document}
Here's an alternative definition to have the rule be the same width as the name of the author of the quote:
\makeatletter
\newcommand\myquote[2]{%
\par
\begin{minipage}{\dimexpr\textwidth-2\parindent\relax}
#1
\par\vspace{1ex}
\noindent
\settowidth\dimen@{\textsc{#2}}%
\ifdim\dimen@>\textwidth
\dimen@\textwidth
\fi
\hspace*{0.5\dimexpr\textwidth-\dimen@}%
\rule{\dimen@}{.4pt}
\par\vspace{1ex}
\centering
\textsc{#2}\par
\end{minipage}
\par}
\makeatother

However, as daleif said in the comment, commands are usually better for shorter pieces of text. Longer ones tend to get messy. You need to balance braces across multiple lines, you need to worry about \long\defs, verbatim doesn't work anymore, and a bunch of other issues. Environments are more natural in the case of big pieces of text (in fact, quoting packages usually use environments). Here are the environment version of the commands above, both of which you use as:
\begin{myquote}{<author>}
<quote>
\end{myquote}
% Fixed length rule
\newenvironment{myquote}[1]{%
\par
\begin{minipage}{\dimexpr\textwidth-2\parindent\relax}%
\def\myquoteauthorname{#1}%
}{%
\par\vspace{1ex}
\noindent
\hspace*{0.25\textwidth}%
\rule{0.5\textwidth}{.4pt}
\par\vspace{1ex}
\centering
\textsc{\myquoteauthorname}\par
\end{minipage}
\par}
% Variable length rule
\makeatletter
\newenvironment{myquote}[1]{%
\par
\begin{minipage}{\dimexpr\textwidth-2\parindent\relax}%
\def\myquoteauthorname{#1}%
}{%
\par\vspace{1ex}
\noindent
\settowidth\dimen@{\textsc{\myquoteauthorname}}%
\ifdim\dimen@>\textwidth
\dimen@\textwidth
\fi
\hspace*{0.5\dimexpr\textwidth-\dimen@}%
\rule{\dimen@}{.4pt}
\par\vspace{1ex}
\centering
\textsc{\myquoteauthorname}\par
\end{minipage}
\par}
\makeatother
\parindenton the left and on the right, the minipage width ought to be\textwidth-2\parindent, not\textwidth-\parindent... right? – frougon Jun 26 '19 at 12:16