I have collected a few command definitions in a separate style file electrons.sty, see below. It essentially uses \upharpoonleft, \downharpoonright, \fboxes, and loops to iterate over shell specifications.
Then you can achieve what you want by
\documentclass{article}
\usepackage{array}% only needed for injecting commands at the beginning of columns in the tabular below
\usepackage{electrons}
\begin{document}
\sffamily
\begin{tabular}{l>{\TextShells}l>{\BoxedShells}l}
N & \subshells{{1s:2}{2s:2}{2p:111}} & \subshells{{1s:2}{2s:2}{2p:111}} \\
O & \subshells{{1s:2}{2s:2}{2p:211}} & \subshells{{1s:2}{2s:2}{2p:211}} \\
F & \subshells{{1s:2}{2s:2}{2p:221}} & \subshells{{1s:2}{2s:2}{2p:221}} \\
Ne & \subshells{{1s:2}{2s:2}{2p:222}} & \subshells{{1s:2}{2s:2}{2p:222}} \\
\end{tabular}
\end{document}

Package electrons: Copy the following code into a file electrons.sty. For the documentation see below.
\RequirePackage{amssymb}
\newcommand\spinup{$\upharpoonleft$}
\newcommand\spindown{$\downharpoonright$}
% Looping over a list of tokens with separator
% \electronLoop{processor}{separator}{list}
\newcommand\electronLoop[3]{%
\bgroup
\def\electronLoopProcessor{#1}%
\def\electronLoopSeparator{\def\electronLoopSeparator{#2}}%
\electronLoopDo#3\relax
\egroup
}
\newcommand\electronLoopDo[1]{%
\ifx\relax#1\else
\electronLoopSeparator
\electronLoopProcessor{#1}%
\expandafter
\electronLoopDo
\fi
}
% \orbital{#electrons: 0,1,2}
\newcommand\orbital[1]{%
\fbox{%
\ifcase#1
\phantom\spinup!\phantom\spindown
\or
\spinup!\phantom\spindown
\or
\spinup!\spindown
\else
\bfseries**\strut
\fi
}%
}
% \orbitals{list of #electrons}
\newcommand\orbitals[1]{\electronLoop\orbital{\hspace{-\fboxrule}}{#1}}
% \subshell{name:list of #electrons}
\newcommand\subshell[1]{%
\subshellX#1\endOfShell
}
\newcommand\subshellX{}
\def\subshellX#1:#2\endOfShell{\doSubShell{#1}{#2}}
\newcommand\subshellBox[2]{%
\begin{tabular}[t]{@{}c@{}}
\orbitals{#2}\[-2pt]
\scriptsize#1%
\end{tabular}%
}
\newcounter{electrons}
\newcommand\subshellText[2]{%
\setcounter{electrons}{0}%
\electronLoop{\addtocounter{electrons}}{}{#2}%
#1$^\arabic{electrons}$%
}
% \subshells{list of shells}
\newcommand\subshells[1]{\electronLoop\subshell\SubShellSep{#1}}
\newcommand\BoxedShells{%
\def\SubShellSep{ }%
\let\doSubShell\subshellBox
}
\newcommand\TextShells{%
\def\SubShellSep{}%
\let\doSubShell\subshellText
}
\BoxedShells

\documentclass{article}
\usepackage{electrons}
\parindent0pt
\begin{document}
\title{The package \texttt{electrons}}
\author{gernot}
\date{2021}
\maketitle
\paragraph{Spins:} \verb"\spinup" gives \spinup, \verb"\spindown" gives
\spindown.
\paragraph{Single orbitals:}
\verb"\orbital{0} \orbital{1} \orbital{2}" gives \orbital{0}
\orbital{1} \orbital{2}.
\paragraph{Multiple orbitals:} \verb"\orbitals{012}" gives \orbitals{012}.
\bigskip
\verb"\BoxedShells" (the default) represents shells as boxes.
\paragraph{Subshell:} \verb"\subshell{2p:221}" gives \subshell{2p:221}.
\paragraph{Multiple subshells:}
\verb"\subshells{{1s:2}{2s:2}{2p:221}}" gives \subshells{{1s:2}{2s:2}{2p:221}}.
\bigskip
\verb"\TextShells" represents shells as text.
\TextShells
\paragraph{Subshell:} Now \verb"\subshell{2p:221}" results in \subshell{2p:221}.
\paragraph{Multiple subshells:} Now
\verb"\subshells{{1s:2}{2s:2}{2p:221}}" results in
\subshells{{1s:2}{2s:2}{2p:221}}.
\end{document}