Right Align Caption with singlelinecheck

You can use the optional argument of \DeclareCaptionStyle to define the special behavior of a onelined caption for an own caption style:

\documentclass{article}
\usepackage{showframe}
\usepackage{graphicx}

\usepackage{caption}

\DeclareCaptionStyle{mystyle}
  {format=plain,%
    textformat=period,
    justification=RaggedRight,
    singlelinecheck=true,
  }% all captions are left aligned

\DeclareCaptionStyle{singlelinecentered}
  [justification=Centering]% centered if single line and no `singlelinecheck=false`
  {style=mystyle}% other captions are left aligned

\DeclareCaptionStyle{singlelineraggedleft}
  [justification=RaggedLeft]% right aligned if single line and no `singlelinecheck=false`
  {style=mystyle}% other captions are left aligned

\captionsetup{style=singlelineraggedleft}

\begin{document}
\noindent
\begin{minipage}{0.5\linewidth}
    \centering
    \includegraphics[width=0.95\linewidth]{example-image}%
    \captionsetup{width=0.95\linewidth}%
    \captionsetup{singlelinecheck=false}%
    \captionof{figure}{Caption on Left}%
\end{minipage}%
\begin{minipage}{0.5\linewidth}
    \centering
    \includegraphics[width=0.95\linewidth]{example-image}%
    \captionsetup{width=0.95\linewidth}%
    \captionof{figure}{Caption on Right}%
\end{minipage}%

\medskip\noindent
\begin{minipage}[t]{0.5\linewidth}
    \centering
    \includegraphics[width=0.95\linewidth]{example-image}%
    \captionsetup{width=0.95\linewidth,style=singlelinecentered}%
    \captionof{figure}{Caption Centered}%
\end{minipage}%
\begin{minipage}[t]{0.5\linewidth}
    \centering
    \includegraphics[width=0.95\linewidth]{example-image}%
    \captionsetup{width=0.95\linewidth}%
    \captionof{figure}{Caption taking up full width}%
\end{minipage}%
\end{document}

enter image description here


An easy solution with floatrow:

\documentclass{article}
\usepackage{showframe}
\usepackage{graphicx}
\usepackage{floatrow, caption}

\captionsetup{%
    format=plain,%
    textformat=period,
    justification=RaggedRight,
    singlelinecheck=true,
}%
\renewcommand\ShowFrameLinethickness{0.3pt}

\begin{document}

\begin{figure}[!htb]
\centering\floatsetup{floatrowsep=qquad}
\captionsetup{font=small}
\begin{floatrow}\captionsetup{singlelinecheck=false}
    \ffigbox[\FBwidth]{%
    \includegraphics[width=0.4\textwidth]{example-image}}%
    {\caption{Caption on Left}}%
%%%
    \ffigbox[\FBwidth]{%
    \includegraphics[width=0.4\textwidth]{example-image}}%
    {\captionsetup{justification=raggedleft}\caption[]{Caption on Right}}%
\end{floatrow}%
\par
\vspace{3ex}
%%%%%%
\begin{floatrow}
    \ffigbox[\FBwidth]{%
 \includegraphics[width=0.4\textwidth]{example-image}}%
 { \caption{Caption Centered}}%
 %%%
    \ffigbox[\FBwidth]{%
 \includegraphics[width=0.4\textwidth]{example-image}}%
 {\captionsetup{format=hang}\caption[]{Long caption taking up full width}}%
\end{floatrow}%
\end{figure}

\end{document} 

enter image description here