how to get URL of media uploaded to WordPress via media_handle_sideload()

To get the URL of the uploaded image/attachment, you can use wp_get_attachment_url() (which always returns the full-sized image URL) or wp_get_attachment_image_url() for image attachment:

// This is how you should call uploadImageToMediaLibrary(); assign the value to $att_id.
$att_id = uploadImageToMediaLibrary($post->ID, $external_url, "custom_alt");
$url = wp_get_attachment_image_url( $att_id, 'full' ); // full-sized URL

But to set the image as the featured image of the post where the image was uploaded to, or any posts actually, then you would use set_post_thumbnail() like so:

$att_id = uploadImageToMediaLibrary($post->ID, $external_url, "custom_alt");
if ( ! is_wp_error( $att_id ) && $att_id ) {
  set_post_thumbnail( $post->ID, $att_id );
}

PS: I revised this answer because using set_post_thumbnail() is much preferred than manually updating the private metadata _thumbnail_id used for post featured images.. =)