WordPress Customizer: Dropdown with Category output

In your foreach loop just do a quick print_r($category) to see all available options.

Than you will see that you can use $category->term_id to get the ID of the term/category, instead of $category->slug.

So for example, by using your code from above:

$categories = get_categories();

$cats = array();
$i = 0;

foreach( $categories as $category ) {

    // uncomment to see all $category data
    #print_r($category);

    if( $i == 0 ){

        $default = $category->term_id;
        $i++;

    }
    $cats[$category->term_id] = $category->name;
} 

print_r($cats);
// Prints for example: Array ( [12] => Child-Cat [2] => Parent-Cat [1] => Uncategorized )