How do I apply friendly URL permalinks to a custom WordPress template?

Add the following code

In your main hooks file (maybe in functions.php)

add_action('init', 'my_custom_rewrite_rules');

Then add this function

function my_custom_rewrite_rules() {

    // The rule
    // Input: archives/publications/countries/kenya
    // Output: archive-template.php?posttype=publications&taxo=countries&slug=kenya
    add_rewrite_rule('archives/publications/countries/([^/]+)/', 'archive-template.php?posttype=publications&taxo=countries&slug=$matches[1]', 'top');

    // Flush the rules (to activate them)
    flush_rewrite_rules();
}

To learn more about regex and rewrite rules, those links might help

And to test your rewrite rules, you can use any plugin you like, but I love this one: Monkeyman Rewrite Analyzer

NOTE Sorry I did not write the rule for you, I really have something that came up and do not have time to write the rule and test it, however, I hope the resources that I provided would help you. Good luck.

NOTE 2 Updated the rule. It is not tested. But this should give you a good start.