If one did not swallow the medicine, the fast is not broken. The leftover taste of medicine in one’s mouth or throat does not break the fast. [Shurunbulali, Imdad al-Fattah]
It is permissible to use the siwak or a toothbrush while fasting. It’s disliked to use toothpaste with the toothbrush because of the likelihood that one may swallow the toothpaste and break the fast. However, if one does not swallow it, then it doesn’t break the fast because a substance did not enter the body cavity.
Barak Allah fikum