If I've understood the problem correctly, you should be able to do this with PHP's output buffering functionality. Something like this (untested):
while ($my_query->have_posts()) : $my_query->the_post();
setup_postdata($post);
ob_start(); // Start buffering
woocommerce_get_template_part('content', 'product');
$output .= ob_get_clean(); // Get the content of the buffer, and end buffering
endwhile;