Okay, I have finally found a configuration that works.
I took the value from PHP of $_SERVER['REDIRECT_HANDLER']
which is application/x-httpd-ea-php81
. (So unfortunately it seems I will have to change this .htaccess rule every time that the PHP version gets updated...?)
Then I put this into the .htaccess file:
<Files test.txt>
AddType application/x-httpd-ea-php81 .txt
</Files>