Take this scenario: Owner A has dog A and has agreed with Owner B to breed dog B. However, dog A does not like dog B. To avoid missing this opportunity, owner A gives dog A medicine that increases sex drive for a higher chance of mating with dog B. Is this legal?
While different countries around the world have laws against animal cruelty, I don't see how any of them would apply here.
If there are no harmful side effects, the drug is legally available for this purpose to the owner, and it is the animals owner agreeing to it or in this case even administering it themselves... that is perfectly legal.
There are various products available that purport to do something like this, a number of which are a brew of natural ingredients. Sildenafil is in fact used for dogs, but "off-label" for heart and lung high blood pressure conditions, and that is a prescription drug (no indication that it works in dogs the way it works in humans). Ignoring the question of efficacy, any given product might be subject to FDA regulation, so you would have to read here for the specific product.