Let us assume that you were high on meth at the time, that you were acting normally (that is, were not smashing windows or other such criminal things), but you had mouth sores and high blood pressure. Let's also assume that you are docile, but don't consent: so you stick around. Even with all of these assumptions working against you, the sheriff cannot force you to take a drug test without a warrant. When he goes to the judge, the judge will not issue a warrant to force you to take a test. Drug tests are forms of searches, which are protected by the 4th Amendment, and they basically require "probable cause" to the effect that you had committed a crime. Given your description of the circumstances, there is no such probable cause (i.e. "most likely that it is true"). The threat to call the sheriff was empty, though perhaps sincerely believed (many people sincerely believe lots of wrong things about the law).
You can consent (sounds like you did): as far as I know, if you give in to a suggestion from a nurse that the sheriff will make you take the test (an untruth), that would not invalidate evidence derived from a voluntary search. Every citizen is expected (unreasonably) to know and follow the law, and it is expected that you will know that you have the right to refuse, so you cannot say "But I didn't know I could refuse".
You always have the right to refuse any medical treatment or testing. This is true even if your insurance requires you to take a certain test. There could be contractual consequences to violating the contract with your insurance company, but again you cannot be compelled to take a test or undergo a procedure because an insurance company "requires" you to. If, for example, your insurance company requires you to take a meth-abuse screening test, then if such a contract condition is legal in California, refusing to take the test could lead to some insurance problems, like they would cancel your policy.
As for financial liability for the test that you didn't really want but agreed to, there is a chance that you could argue in court that you were coerced into the test and thus your apparent consent was not real. You have the right to refuse the test; if the other party, "whether or not acting under color of law, interferes by threat, intimidation, or coercion, or attempts to interfere by threat, intimidation, or coercion, with the exercise or enjoyment by any individual or individuals of rights secured by the Constitution or laws of the United States, or of the rights secured by the Constitution or laws of this state", then they crossed a legal line and you can sue them, plus any "agreement" that is coerced is null in the courts, and the putative debt arising from the test is also null. You simply have to establish that you were coerced, and not convinced.