A good attorney in Brazil isn't one who guides you through the court system: as Texanbrazil points out, the Brazilian court system is extremely slow, and best to be avoided, unless you have the misfortune to be involved in a criminal case, and can't escape it. A good attorney is the one who helps you solve your problem without going anywhere near the courthouse.
Why do you need an attorney?
Most expats need legal advice and/or representation for navigating some issue with the administrative state -- the bureaucracy -- not the judicial one.  This can include immigration issues with the Federal Police, registration issues of every type with the various cartórios, real estate purchases, setting up a business, and so on.  Brazilian attorneys spend a great deal of their professional time dealing with bureaucracies, so this will not seem at all unusual to them.
Understandably, people on this forum are often looking for immigration attorneys, so let's address that right now. While this is a fairly common specialty in English-speaking America, it is not here: 500 years of physical and cultural isolation, at least 70 years of restrictive immigration policies, and the low value assigned to the subject in Brazilian legal education mean that immigration law specialists are very few. Your best bet: find an energetic young general attorney who can still remember her one course of immigration law, who remembers how to do legal research, and will research and press your case enthusiastically.
How do you find a good attorney?
In a high-touch society like this one, the best way is through personal recommendations. Ask friends and acquaintances if they know a good lawyer. If you've been in Brazil long enough to do your taxes, chances are that you know an accountant. My husband and I have found our accountant to be a fantastic resource, not only for finding a good lawyer, but for finding reliable independent professionals in different fields. If you've worked with a real estate agent, they could also be a source, but be careful there: many real estate agents in Brazil are non-practicing lawyers, so be wary of offers to help you from someone whose skills are rusty, in order to get a fee.
If you don't get any recommendations that pan out, the professional legal website jusbrasil.com.br has a search function to find attorneys in your area. We've had some limited success with that.
Once you have names, what do you do?
Interview them! You're looking for someone who seems smart, engaged, knowledgeable, honest, energetic, and interested in your issue. Most attorneys, in my experience, will not try to charge you for this initial consult; if one does, avoid that person.
A good degree isn't a perfect recommendation, but it's a good one. Brazil's two oldest and most prestigious law schools are those of the University of São Paulo, and the Federal University of Pernambuco, in Recife. Graduates of those schools tend to have nationwide networks of contacts, and are disproportionately represented in the ranks of Brazil's judges, senior civil servants, Public Prosecutors, and diplomats. Right up there with them are the larger Catholic Universities ("PUC"'s).
Following them are the State Universities (in the states that have them), and the Federal Universities, in every state. These schools are competitive and demanding, and turn out good lawyers, who tend to have more local and regional networks and practices, except for a couple of national powerhouses like Minas Gerais and Rio Grande do Sul.
Private law schools in Brazil are a very mixed bag; some are good, but many are for-profits who take anyone who can pay, and failed to qualify for one of the options above. Before engaging a graduate from a private school, I'd ask around about the school's local reputation.
What will it cost you?
The OAB -- Order of Brazilian Advocates -- has a price list for all of the most common services, and most of them seem to start around R$1000; so the price list is where discussions start.
In both my professional and personal dealings, I've found recent graduates who recently joined the Bar and are starting up their practices the most willing to negotiate on price, I think that they're also the ones whose knowledge is most current, and who are apt to have good research skills. Your issue is likely to be new to them, or a new twist on an old problem, so it will probably inspire the enthusiasm to pursue it to a successful conclusion. At least, that's been my experience.
Good luck!