.htaccess is a regular, normal text file and can be altered and apended with fopen and fwrite just like any other text file.
The truth is, however, that you shoudn't be letting your users do things that will affect such important files. You can accomplish your goal, here, without altering the .htaccess file. You should store the domain names in a database and do the redirects with PHP, not with .htaccess.