So is it your paying job that is enforcing a dress code, or a place where you are volunteering?
When you accept a job, you are basically going into an agreement with your employer - you agree to follow their rules and do the work, and they agree to pay you for your time. If you are talking about a paying job I'd say just follow the dress code ?
If you are volunteering and they are requesting that you dress a certain way, that is probably because when you are there, you are representing their company/cause. If you don't agree with the dress code they have requested, maybe try volunteering somewhere else? But in my opinion if you want to help them out, and it's just a few hours a week, why not just not wear t-shirts with logos?
Basically either way I'd say just follow the dress code. It sucks sometimes, but is it really worth missing out on a volunteering opportunity or a paying job? No.