It is not possible with the current version of knitr (v1.5), but will be possible in the next version (v1.6), which has not been released yet. If you use the development version on Github, you can actually assign the source code to a code chunk via the code
option, e.g.
<<dot-ex, engine = "dot", code = dotFun()>>=
@
More on this in the news for v1.6.