Adding Categories Through Function

Themes do not have an equivalent of register_activation_hook() like plugins.

You may also run into issues during a review if you’re hoping to be hosted on the repo. I’m not sure how creating categories classifies exactly, but doing things like creating post types is explicitly disallowed.

That said, you can use wp_create_category() in your functions.php file with a check to see if the category exists with term_exists(). Code below is untested.

if(!term_exists('my_category_name','category')) {
    wp_create_category('my_category_name');
}