For hardcopy output you can easily include other packages. This is done by modifying the files in webwork2/conf/snippets. e.g. hardcopyPreamble.tex
loads packages before the homework set is processed by TeX for hardcopy.
Usually TeX is only used to created formula for screen display, so you'll need
to extend some of WeBWorK's code in order to use TeX to draw the figures. You might want to see if the figures couldn't be drawn as easily or more easily (and more quickly) using WeBWorK's WWPlot module instead of xy-pic.
When WeBWorK processes forumulas in image mode it uses the packages defined in webwork2/lib/WeBWorK/Constants.pm ($WeBWorK::PG::ImageGenerator::TexPreamble). If you start customizing this however there is a good chance that what works in image mode (dvipng) won't work in jsMath mode or the other viewing modes.