The problem is the inner []
of the optional argument for \includegraphics
, since LaTeX cannot balance square brackets, the closing ]
of the optional argument is misinterpreted as the closing square bracket for the last optional argument of \titleformat
; to prevent the error, you need to hide the inner square brackets using an extra pair of braces:
\documentclass[draft]{article}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage[demo]{graphicx}
\titleformat{\section}[hang]
{\color{black}\Large\bfseries\filcenter}
{}
{0in}
{\includegraphics[width=\linewidth]{blue.png}}[]
\titleformat{\section}[hang]
{\color{black}\Large\bfseries\filcenter}
{}
{0in}
{}
[{\includegraphics[width=\linewidth]{blue.png}}]
\begin{document}
\section{Test}
\end{document}

As a side note, \bf
shouldn't be used anymore; use \bfseries
instead.
The demo
option for graphicx
simply replaces actual figures with black rectangles; do not use that option in your actual document.
hang
shape. As a confirmation, try to see if it's OK withrunin
shape.