Both can mean working in your garden, but "pracovat na zahradě" is much more common. Especially when you do gardening. When you do some random work there, you can probably say that it is "v zahradě" as well, but "na zahradě" is the normal way to say "in the garden" for me.
For some bigger named gardens (parks) you would say "jsem v Lucemburské zahradě", not "na". "v Getsemanské zahradě" = "in the Garden of Gethsemane"
When you work in a garden as a job, and you take it as an institution and not a location I would say "pracuju v zahradě XY" but "na" is not impossible (although better for "working on" it). When not not mentioning the actual name, you can probably use either. There is also zahradnictví (garden centre) - that would really use "v".