Local bounding box doesn't work inside a scope

You do not need a local bounding box here. You can just use some coordinate in the microphone. However, it is known that pics screw up the name prefixes. This bug has been only fixed partially, and according to Henri Menke it will be fixed completely in the next version of pgf. For the time being, let us use @cfr's solution to reset the name prefixing with name prefix ... This solution is what the pgf manual v3.1.4 recommends on p. 263

enter image description here

Then you can use the tricks from the pgfmanual to give a name to the pic, and to refer to one of its coordinates from outside. This has the additional benefit that you do not have to guess an angle like -45, which will change if you rotate the microphone.

\documentclass[border=0pt]{standalone}
\usepackage{tikz}
\tikzset{
    pics/microph/.style={code={ 
        \draw[black, line width=.2em, rounded corners=1.7ex] 
            (-.85em,4.5ex) -- (-.85em,2ex) -- (.85em,2ex) -- (.85em,4.5ex);
        \path (0,2ex) coordinate (-plug);   
        \fill[black,name prefix ..] % https://tex.stackexchange.com/a/194370 
            (-.6em,5ex) to[rounded corners=1.2ex]  
            (-.6em,2.5ex) to[rounded corners=1.2ex] (.6em,2.5ex)
            -- (.6em,5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)  
            -- (.6em,5.5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6.5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            to[rounded corners=1.2ex]
            (.6em,8ex) to[rounded corners=1.2ex]
            (-.6em,8ex) to cycle; 
   }},
}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (-8.5,-6.5) rectangle (8.5,6.5);
\node[fill=cyan, draw=cyan, minimum width=17cm, minimum height=13cm](sky){};
\pic[rotate=40] (microfono) at (4.5,-5) {microph};
\draw[black, line width=2pt] (microfono-plug)   -- ++(.2,-.2) -- ++(0,-2);
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here


the description of \clip contains the sentence "the size of subsequent paths will not be important for the picture size." So I assume that local bounding box can't get the correct size.

A simple work around is to draw the micro twice:

\documentclass[border=0pt]{standalone}
\usepackage{tikz}
\tikzset{
    pics/microph/.style={code={
        \draw[black, line width=.2em, rounded corners=1.7ex]
            (-.85em,4.5ex) -- (-.85em,2ex) -- (.85em,2ex) -- (.85em,4.5ex);
        \fill[black]
            (-.6em,5ex) to[rounded corners=1.2ex]
            (-.6em,2.5ex) to[rounded corners=1.2ex] (.6em,2.5ex)
            -- (.6em,5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,5.5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6.5ex) to[rounded corners=.2ex] ++(-.85em,0) to[rounded corners=.2ex] ++(0,.35ex) -- ++(.85em,0)
            to[rounded corners=1.2ex]
            (.6em,8ex) to[rounded corners=1.2ex]
            (-.6em,8ex) to cycle;
    }},
}
\begin{document}
\begin{tikzpicture}
%
\begin{scope}
\pic[rotate=40, local bounding box=microfono] at (4.5,-5) {microph};
\clip (-8.5,-6.5) rectangle (8.5,6.5);
\node[fill=cyan, draw=cyan, minimum width=17cm, minimum height=13cm](sky){};
\pic[rotate=40] at (4.5,-5) {microph};
\draw[line width=2pt] (microfono.-45) -- ++(-.2,+.2) ++(.2,-.2) -- ++(0,-2);
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here


As I mentioned in my comments the problem arises with your pic {microph} and not with the first pic {seagull} defined on section 18 Pics: Small Pictures on Paths of the TikZ manual. This clearly shows that there is a bug in the source code of the pic operation. This bug makes the to operations in the code of a pic incompatible.

The problem comes from a bug in the pic operation that does not tolerate to operations. By replacing these operations with --, it works.

You do not need a local box because the pic allow you to place node accessible from the outside with the prefix name as shown on section 18.2 The Pic Syntax of the manual. So I added a coordinate called the (-milieu) to the right where the wire connects: in the middle of the bottom of the microphone.

\draw[black, line width=.2em, rounded corners=1.7ex,pic actions] 
            (-.85em,4.5ex) -- (-.85em,2ex) -- (.85em,2ex)coordinate[midway](-milieu) -- (.85em,4.5ex);

screenshot

\documentclass[border=0pt]{standalone}
\usepackage{tikz}
\tikzset{
    pics/microph/.style={code={ 
        \draw[black, line width=.2em, rounded corners=1.7ex,pic actions] 
            (-.85em,4.5ex) -- (-.85em,2ex) -- (.85em,2ex)coordinate[midway](-milieu) -- (.85em,4.5ex);
        \fill[black,pic actions]  
            (-.6em,5ex)[rounded corners=1.2ex]  --% 
            (-.6em,2.5ex)[rounded corners=1.2ex] --%to 
            (.6em,2.5ex)
            -- (.6em,5ex)[rounded corners=.2ex] --%to 
            ++(-.85em,0)[rounded corners=.2ex]  --%to
            ++(0,.35ex) -- ++(.85em,0)  
            -- (.6em,5.5ex)[rounded corners=.2ex] --%to 
            ++(-.85em,0)[rounded corners=.2ex] --%to 
            ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6ex)[rounded corners=.2ex] --%to 
            ++(-.85em,0)[rounded corners=.2ex]  --%to
            ++(0,.35ex) -- ++(.85em,0)
            -- (.6em,6.5ex)[rounded corners=.2ex] --%to 
            ++(-.85em,0)[rounded corners=.2ex] --%to 
            ++(0,.35ex) -- ++(.85em,0)
            [rounded corners=1.2ex]--%to
            (.6em,8ex) [rounded corners=1.2ex]--%to
            (-.6em,8ex) --%to
             cycle; 
    }},
}

\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (-8.5,-6.5) rectangle (8.5,6.5);
\node[fill=cyan, draw=cyan, minimum width=17cm, minimum height=13cm](sky){};
\pic[rotate=40] (microfono) at (4.5,-5) {microph};
\draw[black, line width=2pt] (microfono-milieu) -- ++(.2,-.2) -- ++(0,-2);
\end{scope}

\end{tikzpicture}


\end{document}