The answer is "yes, it can" but "no, it shouldn't". A little experimenting shows that the node name is available within the shape definition and so it is possible to define a shape hierarchically. For example, the following does the dumbbell.
\makeatletter
\pgfdeclareshape{dumbbell}{
\savedanchor{\center}{%
\pgfpointorigin}
\anchor{center}{\center}
\backgroundpath{
\edef\@temp{%
\noexpand\node[circle,draw] (\tikz@fig@name-left) at (-1,0) {};
\noexpand\node[circle,draw] (\tikz@fig@name-right) at (1,0) {};
\noexpand\draw (\tikz@fig@name-left) -- (\tikz@fig@name-right);
}
\@temp
}
}
So \node[dumbbell,draw] (a) {}; will draw the dumbbell and name it a. The components can be accessed as a-left and a-right. For example:
\begin{tikzpicture}
\node[dumbbell] (a) at (2,0) {};
\draw (a-left) to[out=60,in=120] (a-right);
\end{tikzpicture}
would produce

But there are lots of problems with this code! The first is that I'm using "high level" (ie pure TikZ) commands inside the \pgfdeclareshape which is Not Good. The second is that the paths constructed in the background path are not all One Path. Even if we converted everything to low-level PGF commands, we would still not have a single path but several: one for each of the node components and one for the bit between them (to see this, note that when a node is constructed on a path then it is possible to colour the node boundary a different colour to the main path. This is only possible with separate paths). This makes styling the node paths an absolute nightmare. You would have to ensure that the styles got inherited correctly, but also you have to protect against infinite recursion.
A more robust method would be to do all the actual drawing in the main shape and then add extra nodes as necessary purely for the purpose of having anchors. Off the top of my head, here's an example of that:
\pgfdeclareshape{dumbbell}{
\savedanchor{\center}{%
\pgfpointorigin}
\anchor{center}{\center}
\backgroundpath{
\edef\@temp{%
\noexpand\node[circle,draw=none,fill=none,minimum size=2cm](\tikz@fig@name-left) at (-2,0) {};
\noexpand\node[circle,draw=none,fill=none,minimum size=2cm](\tikz@fig@name-right) at (2,0) {};
}
\@temp
\pgfpathcircle{\pgfqpoint{-2cm}{0cm}}{1cm}
\pgfpathcircle{\pgfqpoint{2cm}{0cm}}{1cm}
\pgfpathmoveto{\pgfqpoint{-1cm}{0cm}}
\pgfpathlineto{\pgfqpoint{1cm}{0cm}}
}
}
(Again, the high-level commands ought to be converted to low-level ones.) Note that I explicitly turn off any rendering commands on the extra shapes. Actually, I would prefer to draw the extra nodes outside the background path just to keep the anchor nodes separate from the main shape. So I think that my actual code would be something a bit like the following:
\documentclass{standalone}
\usepackage{tikz}
\makeatletter
\pgfdeclareshape{dumbbell}{
\savedanchor{\center}{%
\pgfpointorigin}
\anchor{center}{\center}
\backgroundpath{
\pgfpathcircle{\pgfqpoint{-2cm}{0cm}}{1cm}
\pgfpathcircle{\pgfqpoint{2cm}{0cm}}{1cm}
\pgfpathmoveto{\pgfqpoint{-1cm}{0cm}}
\pgfpathlineto{\pgfqpoint{1cm}{0cm}}
}
\beforebackgroundpath{
\tikzset{minimum size=2cm}
{
\pgftransformxshift{-2cm}
\pgfnode{circle}{center}{}{\tikz@fig@name-left}{}
}
{
\pgftransformxshift{2cm}
\pgfnode{circle}{center}{}{\tikz@fig@name-right}{}
}
}
}
\makeatother
\begin{document}
\begin{tikzpicture}
\node[dumbbell,draw,line width=2pt,red,fill=orange] (a) at (2,0) {};
\draw (a-left) to[out=60,in=120] (a-right);
\node[dumbbell,red,draw] (b) at (2,-3) {};
\draw (b-left) to[out=60,in=-120] (a-right);
\end{tikzpicture}
\end{document}

Note that I'm now using the correct low-level commands for the nodes. This means, for example, that they are unaffected by any TikZ options. You can see this by removing the draw from the calling command and adding every node/.style={draw} to the \tikzset inside the definition of the shape. The extra nodes still aren't drawn.
In fact, this looks like a really neat solution to a problem I was (honestly!) pondering with the TQFT package inspired by Topological Quantum Field Theory diagrams with pstricks or tikz, namely how to add sensible anchors to the boundary components. I'm glad you asked this question!
(node.subshape.anchor)notation for some time. However, without hacking PGF this shouldn't be directly possible. But you should be able to simulate this by defining an anchor with the namesubshape.anchorin the\pgfdeclareshape. – Martin Scharrer May 17 '11 at 10:27\anchor{left circle.north west}and also\anchor{right circle.north west}and so on inside my\pgfdeclareshape{dumbbell}. – Bruce Bartlett May 17 '11 at 11:01\deferredanchorin the manual. It seems to be new in the 2.10 version and looks promising. – Martin Scharrer May 17 '11 at 11:06tikzpicture(but not very useful except withoverlay,remember picture). – Martin Scharrer May 17 '11 at 14:18mycirclewhich basically draws a circle and has acenteranchor. Then I declared mydumbbellshape, pertinently, it has a\leftanchorsaved anchor for the left part of the dumbbell, where a circle is supposed to go. Inside the\backgroundpath, I have the code\leftanchor \pgfnode{mycircle}{center}{}{\nodename left circle}{}. Then I get the errorNo shape named D left circle is knownif I attempt to use it in TikZ for a dumbbell named D. – Bruce Bartlett May 17 '11 at 14:28