The easiest way is simply include it and return the output captured in an output buffer, so your snippet would simply consist of something like this:
<?php
ob_start();
include($modx->config['base_path'] . 'assets/snippets/mycode/myform.php');
$output = ob_get_contents();
ob_end_clean();
return $output;
?>
However, it’s better (in my opinion) to separate the markup from the PHP by putting the markup in the document content, or a chunk, and the PHP in a snippet. You can turn the echo’s into placeholders in the content or chunk: consider $modx->setPlaceholder(’sum’, $sum); for instance, and then placing [+sum+] in your content, a chunk, or even a TV, where the <?php echo $sum ?> exists now.