I need a custom permalink for my website

I’m not sure if I should assume that you were issuing your examples inside of the init hook, but if not that is the reason they weren’t working for you.

So inside functions.php

function sd_rewrite_rules() {
  add_rewrite_tag('%domain_name%', '([^&]+)');
  add_rewrite_rule('^/([^/]*)/?','index.php?domain_name=$matches[1]','top');
}
add_action('init', 'sd_rewrite_rules', 10, 0);

Then if you wanted to retrieve the query variable to do something with it, you would do something like this in a page template file using the $wp_query global.

$domain_value = $wp_query->query_vars['domain_name'];

Everything you would want to know plus more can also be located by reading all about the Rewrite_API and it has tons of examples of doing other things you might find interesting or relevent.

https://codex.wordpress.org/Rewrite_API