KOMA-Script and sidenotes : how to format side (margin) caption and its caption label?

The sidenotes package uses package caption to define a caption style sidecaption. You can redeclare this style:

\documentclass{scrartcl}
\usepackage[T1]{fontenc}% <- added
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{sidenotes}

\DeclareCaptionStyle{sidecaption}{labelfont={sc,bf},justification=raggedright}
\begin{document}
    \lipsum
    \begin{figure}[htb]
        \sidecaption[][-2\baselineskip]{This is my caption}
        \includegraphics[width=\textwidth, height=20em]{example-image-a}
    \end{figure}
    \lipsum
\end{document}

enter image description here


Or with the KOMA-Script environment captionbeside:

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{graphicx}

\setkomafont{captionlabel}{\scshape\bfseries}

\usepackage{etoolbox}
\BeforeBeginEnvironment{captionbeside}{%
  \setcapindent*{0pt}%
  \setcaptionalignment{l}% needs KOMA-Script Version 3.25; workaround for older versions: \addtokomafont{caption}{\raggedright}%
}

\begin{document}
\lipsum
\begin{figure}[htb]
\begin{captionbeside}{This is my caption}
    [o]% caption on the outer document side
    [\dimexpr\textwidth+\marginparwidth+\marginparsep\relax]% enlarge the used width
    [0pt]*% align with the inner margin
  \includegraphics[width=\textwidth, height=20em]{example-image-a}
\end{captionbeside}
\end{figure}
\lipsum
\end{document}

enter image description here

Or with option captions=topbeside and a raised image:

\documentclass[%
  captions=topbeside% change the position of the sidecaption to the top baseline
]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{graphicx}

\setkomafont{captionlabel}{\scshape\bfseries}

\usepackage{etoolbox}
\BeforeBeginEnvironment{captionbeside}{%
  \setcapindent*{0pt}%
  \setcaptionalignment{l}% needs KOMA-Script Version 3.25; workaround for older versions: \addtokomafont{caption}{\raggedright}%
}

\begin{document}
\lipsum
\begin{figure}[htb]
\begin{captionbeside}{This is my caption}
    [o]% caption on the outer document side
    [\dimexpr\textwidth+\marginparwidth+\marginparsep\relax]% enlarge the used width
    [0pt]*% align with the inner margin
  \raisebox
    {\dimexpr-\totalheight+\ht\strutbox\relax}
    {\includegraphics[width=\textwidth, height=20em]{example-image-a}}
\end{captionbeside}
\end{figure}
\lipsum
\end{document}

enter image description here


KOMA-Script has its own captionbeside environment (see manual page 121). With that \addkomafont changed the font for the caption as you wish.

Please see the following MWE:

\documentclass{scrartcl}

\usepackage{lipsum}
\usepackage{graphicx}
%\usepackage{sidenotes}

\setkomafont{captionlabel}{\scshape\bfseries}


\begin{document}
\lipsum
\begin{figure}[htb]
\begin{captionbeside}{This is my caption}%
   [r]
  \includegraphics[width=.7\textwidth]{example-image-a}
\end{captionbeside}
\end{figure}

\lipsum
\end{document}

with the result:

enter image description here

If you want to use \sidecaption you have to use package caption to influence the formating of the caption because package sidenotes calls caption internally ...