Unable to change the “Read more” text inside the_excerpt

Try making the post object accessible using global and use get_permalink($post->ID)

function new_excerpt_more( $more ) {
    global $post;
    return '<a class="read-more" href="'. get_permalink($post->ID) . '">Custom text</a>';
}
add_filter( 'excerpt_more', 'new_excerpt_more' );

Ensure the code is in your functions.php file.