pdfcomment offers an interface to PDF annotations (section 8.4, page 604 in PDF Reference, sixth edition ,Adobe® Portable Document Format, Version 1.7, November 2006, Adobe Systems Incorporated)
There's no secret, pdfcomment just uses pdflatex's \pdfannot primitive. It takes care of the 'over head' and pdfcomment just adds some meat to the bone, e.g.:
\newcommand{\pc@annot@markup@pdf}%
{%
\pdfannot width 0pt height 0pt depth 0pt%
{%
/Subtype /\pc@lopt@markup\space%
/C [\pc@hyenc@color]\space%
\pc@lopt@cdate\space%
/CA \pc@lopt@opacity\space%
/T (\pc@pdfenc@author)\space%
/Subj (\pc@pdfenc@subject)\space%
/Contents (\pc@pdfenc@contents)\space%
/Open \pc@lopt@open\space%
/QuadPoints [\pc@annot@quadpoints]\space%
/F 4\space%
}%
}%
Other engines need different approaches like \special{pdf: ann width 0pt height 0pt depth 0pt% (dvipdfmx) or \pdfmark[\rule{0pt}{0pt}]% (dvips).
You can not really add a LaTeX macro like \frac{1}{2} into a \pdfcomment macro, as the standard text PDF annotations (there are also others like audio annotations, stamps, ...) are designed as 'text only' in the PDF format by Adobe. You may add some mathematical symbols and so on in Unicode
For complex material you need a completly different approach like fancytooltip or AlexG's hacking in Javascript, see e.g. Move-around box in PDF display