You can use
https://codex.wordpress.org/Function_Reference/get_terms
to return the needed data for the select, and store the selected values (term IDs) in options table using
https://codex.wordpress.org/Function_Reference/update_option
The ‘hide_empty’ param in ‘get_terms’ will prevent returning categories with no posts.