Echo all category names, apart from one

the_category echos content. You will not be able to use string manipulation. No strings are returned that you could manipulate. They are just echoed immediately.

You could completely filter out a particular category, which seems to be an option, with this:

function cat_filter_wpse_137596($categories) {
  foreach ($categories as $k => $c) {
    if ('uncategorized' === $c->slug) {
      unset($categories[$k]);
    }
  }
  return $categories;
}

You’d use it like:

    add_filter('get_the_categories','cat_filter_wpse_137596');
    if (is_category() || is_single()) {
        the_category("https://wordpress.stackexchange.com/");
        if (is_single()) {
            echo "https://wordpress.stackexchange.com/" . '<a href="#">' . get_the_title() . '</a>';
        }
    } elseif (is_page()) {
        echo "https://wordpress.stackexchange.com/" . '<a href="#">' . get_the_title()  . '</a>';
    }
    remove_filter('get_the_categories','cat_filter_wpse_137596');

There is no easy way to keep the category and remove the link. You’d need some nasty regex on the the_category filter.