There are three ways to do this
Functions.php
Put your additions in functions.php and back up that file before you update your theme. Then you can port over any additions as necessary.
Child theme
Build a child theme that adds the functionality – in reality, this would be an even better way to use a custom functions.php file because it wouldn’t be overwritten by updates.
Custom plug-in
Completely isolate the new functionality from the theme and add it in using WordPress’ hooks and filters. This way, you lose nothing in upgrades and can selectively turn off features if/when native support is added by the themes.