Yes, you can move a website from one domain to different domain and maintain the ranking.
This is very common when business re-branding is done and website needs to move from one domain to a different domain.
All you need to do is, set a permanent 301-redirection from your old domain to the new domain. Set the permanent redirection at domain level so that every single page of your website automatically will get redirected to respective pages on the new domain.
Let's say you had:
Now let's assume you wanted to move to myexample.com. Then set the redirection at the domain level and each page will get redirected to its respective page on the new domain like:
example.com => myexample.com
example.com/page1 => myexample.com/page1
example.com/page2 => myexample.com/page2
Important: also, worth using Google change of address tool to ensure a smooth transition and minimizing the impact on current ranking. You can do this once the transfer will be complete.
You may also consider doing the following to make the transition smooth:
1) Must have 301-redirection from the old domain to the new domain.
2) Validate ownership of new domain in Google Search Console.
3) Submit XML-sitemap of the new domain.
Note: When you will do the transfer and above steps, for certain time (days, weeks) you may see your old website in the search result and slowly the ranking will move to the new domain and old website pages will start to disappear.