This might depend on where you live. It is possibly legal, but also likely unethical.
Did your doctor give you a specific reason for refusing medication without a COVID test?
Is this a prescription you are trying to fill by phone? If it's a med you've been taking, there's no reason to see the physician in person. Is there something in the medication that might harm you if you have covid? I can see, for example, that a doc might be wary of blood thinning meds, and there are a ton of supplements, foods, and drugs that have some effect on that, for someone with covid and its clotting action. Did you ask why?