In my magento admin area, admin can set a name to be displayed on the contact us page. For example, admin can set "contact-us" as the url-alias and I want to set that as the frontname of my contacts module. How to do that programatically?
You don't necessarily have to do that programmatically, you can do it from the backend.
Go to Catalog > Url Rewrites.
Go to Marketing > URL Rewrites.
Step by step
Click the Add URL Rewrite button.
Choose Custom in the drop down.
ID Path: contact-us
Request Path: contact-us
Target Path: contacts
Finally click the Save button.