If you just want something in same style, without using the useful node shapes of tikz then you can do the following. I have updated the code so it works in captions too, the replacement is to use \newrobustcmd from the etoolbox package instead of \newcommand:

\documentclass{article}
\usepackage{etoolbox}
\usepackage{tikz}
\newrobustcmd*{\square}[1]{\tikz{\filldraw[draw=#1,fill=#1] (0,0)
rectangle (0.2cm,0.2cm);}}
\newrobustcmd*{\mycircle}[1]{\tikz{\filldraw[draw=#1,fill=#1] (0,0) circle [radius=0.1cm];}}
\newrobustcmd*{\mytriangle}[1]{\tikz{\filldraw[draw=#1,fill=#1] (0,0) --
(0.2cm,0) -- (0.1cm,0.2cm);}}
\begin{document}
\listoffigures
\section{Sample}
A square \square{red}, a circle \mycircle{green} and a triangle \mytriangle{blue}.
\begin{figure}[htp]
\centering
A figure
\caption{A square \square{red}, a circle \mycircle{green} and a triangle \mytriangle{blue}.}
\end{figure}
\end{document}
An alternative using node shape is as follows. Whilst there are more options to set, this is countered by more predefined shapes to choose between. See the pgf manual:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\newcommand{\square}[1]{\tikz{\node[draw=#1,fill=#1,rectangle,minimum
width=0.2cm,minimum height=0.2cm,inner sep=0pt] at (0,0) {};}}
\newcommand{\mycircle}[1]{\tikz{\node[draw=#1,fill=#1,circle,minimum
width=0.2cm,minimum height=0.2cm,inner sep=0pt] at (0,0) {};}}
\newcommand{\mytriangle}[1]{\tikz{\node[draw=#1,fill=#1,isosceles
triangle,isosceles triangle stretches,shape border rotate=90,minimum
width=0.2cm,minimum height=0.2cm,inner sep=0pt] at (0,0) {};}}
\begin{document}
A square \square{red}, a circle \mycircle{green} and a triangle \mytriangle{blue}.
\end{document}
pictureenvironment. Or enhaced bypict2epackage. – Manuel Jul 08 '14 at 11:12