Here is a tcolorbox-based attempt:


\documentclass{scrartcl}
\newtheorem{theorem}{Theorem}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\usepackage{tikz}
% Definition of \mydangersymbol taken from: https://tex.stackexchange.com/a/604048/134144
\newcommand{\mydangersymbol}[1]{%
\begin{tikzpicture}[baseline=(x.base)]
\draw[rounded corners=.01em] (-.05em,-1.3em)rectangle(.05em,.9em);
\draw[fill=white,rounded corners=1] (0,.8em)--(.8em,0)--(0,-.8em)--(-.8em,0)--cycle;
\drawvery thick,line cap=round--(.3em,-1.3em);
\node(x) at (0,0em) {\normalfont\sffamily\small#1};
\end{tikzpicture}%
}
\NewTColorBox{mydangerenv}{+O{}}{%
enhanced,
sharp corners,
colback=white,
coltitle=black,
title={\mydangersymbol{#1}},
attach boxed title to top left ={yshift=-\tcboxedtitleheight/2-4pt,
yshifttext=-\tcboxedtitleheight/2-4pt,
xshift=-\tcboxedtitlewidth/2+0.25mm},
boxed title style={colback=white,
colframe=white,
sharp corners,
boxsep=0pt,
boxrule=0pt,
bottom=3pt,
halign title=flush center},
boxrule=0.5mm,
top=-\tcboxedtitleheight/2+5pt,
boxsep=5pt,
}
\begin{document}
\begin{mydangerenv}[A]
\begin{theorem}
\lipsum[1]
\end{theorem}
\end{mydangerenv}
\end{document}
yshiftvalues and thetop=value. – SebGlav Jul 11 '21 at 09:33yshiftwas determined manually, so there may still be room for improvement. – leandriis Jul 11 '21 at 09:45