No, as it needs to be done on the individual server and that normally means putting the code outside of the theme folder (either wp-config.php or htaccess).
You could provide a htaccess file with the code but that will confuse buyers, just have a mention of the error in your theme documentation and in the FAQ’s on Themeforest.