Creating a function that sanitizes the custom metabox excerpt

I am not sure this a WordPress question. It is really more just bad PHP but since that is a filter, in the spirit of fostering good will…

Your function is returning a variable-name function that doesn’t exist, and none of your operations are saved at all. You are processing the string but you aren’t keeping the changes. You need to assign the results to a variable. And, you aren’t feeding the function any information to start with.

$text_excerpt = "test";
function vs_trim_excerpt($text_excerpt) {
    $text_excerpt = trim($text_excerpt);
    $text_excerpt = ucfirst($text_excerpt);
    $text_excerpt = wordwrap($text_excerpt, 150);
    return $text_excerpt;
} 
echo vs_trim_excerpt($text_excerpt);

That should work better.