It's not directly possible to query the guild information of anyone besides yourself.
You can however build a lookup table from your roster and then match the name of the unit you are looking at. This is how I do it in
Social Indicators, which makes spotting guild members practical since almost two years.