In a comment, I had mentioned the possibility of using \unslant on the Greeks, as done here: Upright Greek font fitting to Computer Modern. However, the OP wants a macro that does it automatically.
Here, I create a macro \mathgr{} that employs a token cycle to check each token in the argument...if they are \up<greek> able, it uses the \unslant upon them (i.e., it only uses upgreek to determine the token's greek-ness).
Because tokcycle collects the tokens before typesetting them, things like macros and grouped arguments pose no difficulty. For example, in the MWE, in the \mathgr argument, I use non-greek macros, I use groupings around an exponent, I use non greek characters, I use an active ~ token, as well as a nested \textrm.
The \ThisStyle{...\SavedStyle...} syntax of the scalerel package is used to preserve smaller math styles for the unslanted characters.
This approach only works in pdflatex.
\documentclass{article}
\usepackage{upgreek}% ONLY USED TO DEFINE NAMES \up...
\usepackage{tokcycle,scalerel}
\newsavebox{\foobox}
\newcommand{\slantbox}[2][0]{\mbox{%
\sbox{\foobox}{#2}%
\hskip\wd\foobox
\pdfsave
\pdfsetmatrix{1 0 #1 1}%
\llap{\usebox{\foobox}}%
\pdfrestore
}}
\newcommand\unslant[2][-.25]{\ThisStyle{\slantbox[#1]{$\SavedStyle#2$}}}
\makeatletter
\newcommand\mathgr[1]{\tokcycle
{\addcytoks{##1}}
{\processtoks{##1}}
{\ifcsname up\expandafter@gobble\string##1\endcsname
\addcytoks{\unslant{##1}}%
\else\addcytoks{##1}\fi}
{\addcytoks{##1}}{#1}%
\expandafter\mathrm\expandafter{\the\cytoks}%
}
\makeatother
\begin{document}
\begin{tabular}{ll}
slanted greek math-mode letters: &
$ab c \alpha\beta\gamma^{\pi+1}\dots\mu~\nu\dots\omega\textrm{a b c}$ \
tokcycle + unslant &
$\mathgr{ab c \alpha\beta\gamma^{\pi+1}\dots\mu~\nu\dots\omega\textrm{a b c}}$
\end{tabular}
\end{document}

If one was happy with the look of upgreek and wanted to avoid the vagaries of \unslant, then the token cycle can be adjusted to do so:
\documentclass{article}
\usepackage{upgreek}%
\usepackage{tokcycle}
\makeatletter
\newcommand\mathgr[1]{\tokcycle
{\addcytoks{##1}}
{\processtoks{##1}}
{\ifcsname up\expandafter@gobble\string##1\endcsname
\addcytoks[1]{\csname up\expandafter@gobble\string##1\endcsname}%
\else\addcytoks{##1}\fi}
{\addcytoks{##1}}{#1}%
\expandafter\mathrm\expandafter{\the\cytoks}%
}
\makeatother
\begin{document}
\begin{tabular}{ll}
slanted greek math-mode letters: &
$ab c \alpha\beta\gamma^{\pi+1}\dots\mu~\nu\dots\omega\textrm{a b c}$ \
tokcycle + unslant &
$\mathgr{ab c \alpha\beta\gamma^{\pi+1}\dots\mu~\nu\dots\omega\textrm{a b c}}$
\end{tabular}
\end{document}

SUPPLEMENT
The OP seems determined to "override" \mathrm. While I don't recommend replacing it, nonetheless, it can be done to automatically include the token cycle with
\documentclass{article}
\usepackage{upgreek}% ONLY USED TO DEFINE NAMES \up...
\usepackage{tokcycle,scalerel}
\newsavebox{\foobox}
\newcommand{\slantbox}[2][0]{\mbox{%
\sbox{\foobox}{#2}%
\hskip\wd\foobox
\pdfsave
\pdfsetmatrix{1 0 #1 1}%
\llap{\usebox{\foobox}}%
\pdfrestore
}}
\newcommand\unslant[2][-.25]{\ThisStyle{\slantbox[#1]{$\SavedStyle#2$}}}
\makeatletter
\newcommand\mathgr[1]{\tokcycle
{\addcytoks{##1}}
{\processtoks{##1}}
{\ifcsname up\expandafter@gobble\string##1\endcsname
\addcytoks{\unslant{##1}}%
\else\addcytoks{##1}\fi}
{\addcytoks{##1}}{#1}%
\expandafter\svmathrm\expandafter{\the\cytoks}%
}
\let\svmathrm\mathrm
\renewcommand\mathrm[1]{\mathgr{#1}}
\makeatother
\begin{document}
\begin{tabular}{ll}
slanted greek math-mode letters: &
$ab c \alpha\beta\gamma^{\pi+1}\dots\mu~\nu\dots\omega\textrm{a b c}$ \
mathrm (tokcycle + unslant) &
$\mathrm{ab c \alpha\beta\gamma^{\pi+1}\dots\mu~\nu\dots\omega\textrm{a b c}}$
\end{tabular}
\end{document}