I usually do so by asking them out, but it would save me some time and effort to just know they are taken. I feel asking "do you have a boyfriend/are you married?" is a shit way of letting them know you are interested in pursuing them romantically.