Somebody has asked Markus. There are two suggestions on the KOMA-Script website: Überschriften am äußeren Rand ausrichten mit Nummer im Rand (German). Both suggestions needs some runs to get the numbers right.
The first solution needs KOMA-Script version 3.19a or newer. I have changed this code a little so it works now with longer section titles too.
\documentclass[chapterprefix]{scrbook}
%\providecommand*\Ifthispageodd{\ifthispageodd}% needed up to and including KOMA-Script version 3.27, see https://komascript.de/faq_deprecatedif
\usepackage{blindtext}% dummy text
\renewcommand*{\raggedsection}{\Ifthispageodd{\raggedleft}{\raggedright}}
\renewcommand*{\sectionlinesformat}[4]{%
\ifthispagewasodd
\parbox[t]{\linewidth}{\leavevmode\raggedsection#4}\makebox[0pt][l]{\hskip\marginparsep #3}%
\else
\makebox[0pt][r]{#3\hskip\marginparsep}#4%
\fi
}
\renewcommand*{\sectionformat}{\thesection\autodot}
\renewcommand*{\subsectionformat}{\thesubsection\autodot}
\renewcommand*{\subsubsectionformat}{\thesubsubsection\autodot}
\begin{document}
\chapter{A Chapter}
\section{A section with a long, long, long title that needs more than one line}
\Blindtext
\section{Another section}
\blindtext
\blinddocument
\end{document}


The second example uses package marginnote
but works also with older KOMA-Script versions.
\documentclass[chapterprefix]{scrbook}
%\providecommand*\Ifthispageodd{\ifthispageodd}% needed up to and including KOMA-Script version 3.27, see https://komascript.de/faq_deprecatedif
\usepackage{marginnote}
\usepackage{mwe}
\renewcommand*{\raggedsection}{\Ifthispageodd{\raggedleft}{\raggedright}}
\renewcommand*{\sectionformat}{%
\marginnote{%
\usekomafont{disposition}{\usekomafont{section}{%
\thesection\autodot}}}}
\renewcommand*{\subsectionformat}{%
\marginnote{%
\usekomafont{disposition}{\usekomafont{subsection}{%
\thesubsection\autodot}}}}
\renewcommand*{\subsubsectionformat}{%
\marginnote{%
\usekomafont{disposition}{\usekomafont{subsubsection}{%
\thesubsubsection\autodot}}}}
\begin{document}
\chapter{A chapter}
\section{A section with a long, long, long title that needs more than one line}
\Blindtext
\section{Another section}
\blindtext
\blinddocument
\end{document}