How to add a count in a custom tab in a Buddypress group

You are using the BP Nouveau templates, correct? Span tag works fine in the Legacy templates.

In Nouveau, all links are stripped of span tags.
See the calls to function _bp_strip_spans_from_title and functions like bp_nouveau_get_nav_link_text in buddypress\bp-templates\bp-nouveau\includes\template-tags.php.

So remove your span tag from the create subnav item function.

Instead, in Nouveau, use 2 filters for adding a count item.

So something like:

function masta_add_namings_count( $count, $nav_item, $displayed_nav ) {

    if ( $displayed_nav == 'groups' ) {

        if ( $nav_item->slug == 'namings' ) {

            $count = true;

        }

    }

    return $count;

}
add_filter( 'bp_nouveau_nav_has_count', 'masta_add_namings_count', 99, 3 );


function masta_add_namings_count_int( $count, $nav_item, $displayed_nav ) {

    if ( $displayed_nav == 'groups' ) {

        if ( $nav_item->slug == 'namings' ) {

            $group_id = bp_get_current_group_id();

            $count = 666; // pass the group_id to a function that returns the proper count

        }

    }

    return $count;

}
add_filter( 'bp_nouveau_get_nav_count', 'masta_add_namings_count_int', 99, 3 );