Let me extend the answer of Aubrey Blumsohn with a little modification.
With tcbox width=auto limited, the box will switch to break the lines, if the maximum width is reached. This feature is quite new (2015-03-23). You may need to update the tcolorbox package for it.
\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage[skins,breakable]{tcolorbox}
\titleformat{\section}
{\LARGE\bfseries\selectfont}
{}{0pt}
{\tcbox[
tcbox width=auto limited,% <-----------
enhanced,
%boxrule=0pt,
rightrule=0pt,
toprule=0pt,
bottomrule=0pt,
leftrule=3pt,
arc=0pt,
outer arc=0pt,
left=5pt,
interior code={\shade[bottom color=gray!20, top color=white] (frame.north west) rectangle (frame.south east);},
]{\thesection\hskip0.7em#1}}
\begin{document}
\section{Section name}
\section{Section name longer}
\section{Section name extremely long}
\section{Section name extremely long and longer}
\section{Section name extremely long extremely long extremely long extremely long extremely long extremely long extremely long extremely long extremely long extremely long extremely long extremely long extremely long }
\end{document}
