This can be easily done from WordPress settings.
Go to the admin panel of your WordPress site (also known as the Dashboard), and from the left menu, go to Settings ⟹ Permalinks:
From there, you’ll see the Category base input field.
Use the prefix you want in this input field, e.g. my-custom-prefix/category and then Save Changes.
If this is a new site, then this should be enough, no need to do any code change. After this change, your category Page URL sample.com/category/top-10 will become sample.com/my-custom-prefix/category/top-10.
If this is an old site with old category links, then in addition to the above step, it’s better to redirect the older category links using either a redirect plugin or .htaccess.
Following are a couple of links with some additional details about categories that may be helpful to you:
