Use a use
statement:
add_filter( 'single_template', function ( $template ) use ( $name ) {
Or just pass all templates at once, and create just one function:
add_filter( 'single_template', function ( $file ) use ( $templates ) {
global $post;
if ( in_array ( $post->post_type, $templates ) )
return __DIR__ . "/{$post->post_type}.php";
return $file;
});