Absolutely. As a condition for your pretrial release, it is an understood condition that you break no law of the State of Texas (TX Code of Criminal Procedure Arts. 17.03, 17.44). If you are out on bond, the judge can order you to submit to a urinalysis at any time. That's just a fact of life. A positive test for marijuana could be used against you in your criminal case and might allow the State to argue that the marijuana accounts for the intoxication clues the officer will testify about and that you may have been intoxicated by marijuana (which allows them to explain away the passing breath test). In some of the courts I've practiced in, prosecutors will ask for a urinalysis before they offer any kind of a reduction where they suspect a person may be using drugs. A failed test in that circumstance could mean a good pretrial result would become a situation where you might have to have a trial.
The bottom line is that you should not be using any type of illegal drug (and usually should not be consuming any alcohol) while out on a DWI bond. It can cause you a lot of problems and piss off all the wrong people. Talk to your lawyer if you have any questions about how and whether pretrial drug screenings are routinely done in your court.
Disclaimer: This answer is provided as a public service and as a general response to a general question, it is not meant, and should not be relied upon as specific legal advice, nor does it create an attorney-client relationship.
The court certainly has the authority to impose drug testing as a condition of your bond. I assume the pertinent question form your perspective is whether or not your bond can be revoked if you are tested and come up dirty. If the drug testing was required as a condition of your bond when you were released, the answer is yes, your bond can be revoked. However, as I read Texas Code of Criminal Proceure 17.03, 17.40 and 17.44, if the drug testing condition was not specified prior to a dirty drug test, you cannot be revoked on that basis. Of course, the court is free to amend the conditions of your bond such that any future violations would form the basis to revoke your bond.
Interestingly, according to 17.03(d), the state may not use the results of any dirty drug tests in the case against you.
Bristol is absolutely correct; TX Code of Criminal Procedure 17.03(d) prohibits the State form using any evidence obtained as a result of a drug test while out on personal bond against a criminal defendant.
What I meant by "using this against you" is that the State can pull any deal they have off the table and pressure to either accept a bad offer or to go to trial. By giving them a hot UA, you run the risk of ruining any chance you have of getting a guaranteed result (dismissal of DWI). They can still argue that the officer suspected intoxication by some other drug, and case law says they don't have to prove what drug that was. This is a much, much more difficult case for the State to prove, to be sure. A failed test is exactly the kind of thing that might just piss off a prosecutor enough to say to you "Let's let a jury decide". Not something that's the end of the world, but it's something that limits your options.
If you are asking if they can test you now to get evidence that you were under the influence of marijuana at the time of your arrest, the answer is no. While drugs stay in the hair where it is put in at the follicle at the time of use and they can guess how long ago you used, they cannot say with certainty. Moreover, just because you drink beer today, doesn't mean you were drinking beer that day. The same theory applies with using marijuana - just because you tested dirty today does not mean you had used that day.
What they generally do with a DWI (it is still DWI unless you are under 21 - it just lists a drug intoxicant rather than alcohol), is have a drug recognition expert give you different tests that are purported to help determine the use of drugs. Moreover, when it is marijuana, they will look in your mouth & throat & say that they saw green (which indicates the recent use of marijuana.)