TL;DR
Yes, carbon might be your best bet. I would not bet my life on such a thing if I had not already practiced it though. Carbon is used to filter purify both water (your typical Brita water filter) and air (re-breathers for divers' air), so the potential is there. Farther down I discuss how I would approach this since I have made filters before.
I have heard claims that simply wetting the bandana can improve its filtering ability. I have never seen anything to lend great credibility to this, but it makes sense. It probably would not improve by much though, as all it would take is 1 small spot to dry up for the air to go through that spot instead. Maybe if you kept soaking it frequently, but then you would need to be stationary and constantly dipping your face into a lot of water. This does not sound like something I would bother to try except in an emergency in which I was stuck in one place anyway.
As far as crafting something, yes, good carbon would be the first thing many of us would think of. I will warn you from experience though, as I have been doing a lot of playing around with this kind of survival crafting; you need to be careful or you could just make matters worse for yourself by inhaling the carbon dust, ash, or other fire byproducts. I accidentally did this recently and got a face and breath full of stinky fire byproducts and did a lot of coughing for a few minutes. Maybe you could improvise a dust mask for... never mind. ;)
If you want to go the carbon route
Obviously you need a source of carbon
I am going to assume that you are sourcing your carbon from the wild rather than bringing activated carbon with you on your trip.
First, make sure you actually have good carbon for this. Simply taking the black stuff out of a fire is not going to give you the best charcoal. You need to make sure that you drive off as much of the non-carbon chemicals as you can from the wood. I won't go into details, as that would be an answer to a different question ("How do I make good charcoal?" could be a good TGO.SE question if not already asked, or you could Google that). But I will say, since many charcoal tutorials don't, that if you want as pure carbon as you can get, make sure you burn it hot. Different chemicals come out at different temperatures, so you can have what looks like great charcoal that could still be reduced closer to pure carbon if it comes from a low-temp fire.
Preferably activated carbon (though not necessarily)
Even if you get as good quality charcoal as you can, calling it "activated carbon" is still questionable at this stage. Different people mean different things when they say activated carbon. Usually it is considered activated when you have processed the carbon by increasing the size of the pores within it. There are various ways of doing that to activate your carbon, most of which are not applicable to the situation you describe. Again, I will gloss over the step of activating and suggest that is another question ("How can I activate my own carbon?"). Even if you do not activate your carbon, that doesn't mean it is useless for your situation. Activating it just makes it work better.
It should be powdered carbon
So let's say you have made good charcoal and want to use it as your source of carbon in your mask. Generally, carbon is ground into powder so that the gas or liquid to be filtered and purified can move through it. In the situation you describe, you should just make it into the finest dust that you are capable of. When I have done this in the past, I have set the charcoal out on a flat surface and broken it with a stick until it was small pieces, then squished the small pieces with the end of the handle of my knife. If that doesn't get it small enough, I just try to find whatever nearby seems like it will work best to get it into a powder. If you have good stones for grinding, that could work; preferably non-porous stones so it doesn't get caught in the stone.
Now to make the device...
Now you have your filtration/purification vector, the carbon, but you still need to get it into a form that will actually work for you. This is where your situation is going to start diverging from my experience unfortunately, as I have done this to filter water for drinking but not air for breathing.
When I did this in the past, I would use paper if I had it, or the biggest leaf I could find, fill it with the pulverized charcoal, poke some tiny holes in the bottom, and start slowly filtering water through it. Even the muddiest, nastiest, dirtiest water came through looking clean as bottled water out the bottom.
For you, though, we need to get it over your mouth and the air moving through it...
If I were to attempt this, I would fold the bandana over once or twice if it's big enough, to add more layers to help keep charcoal out of my mouth. I would mix some water with some dirt to make some mud and make a circle of mud on the bandana. Not thin, runny mud, but rather thick mud that will hold its shape well, to make a little circle wall about the size of my mouth opening. Fill it with the carbon (crunched, good quality charcoal), and put something on top of it to hold the charcoal in. My first guess is a leaf with little holes poked into it, though I'm not sure how well that would work... I (and you) would have to experiment a little.
Once all that were made, I would hold it up to my mouth and seal the edges with more mud so that air cannot go around it.
My thoughts on this device
So there is a forest fire nearby and the smoke is choking you out - this is not the time to be wasting on crafting the thing I just described. You would be much better off just getting yourself out of the forest fire.
So a dust storm kicks up - if you had no advance warning, you have no time to make this. If you do have advance warning, hopefully making this device is not your best option available.
If all you have is the bandana and your other normal gear and you want to make this, it will take hours. If you want really good quality charcoal in the setting you describe, you generally don't make it and use it same day, rather you make it (in the fire) and use it next day after it has thoroughly cooled. So it will take an hour to a day just to get the charcoal if not already available, then gathering the other resources and crafting it takes a while too. It might sound simple, but it's not. The water filters I make are more simple than this, and I usually have to make a few attempts as parts break during the process.
I would guess that it would take me at least a few hours the first time I tried to craft this and have it ready to use, and that is if I had all the pieces on hand ready to start putting them together. After making a few practice ones, and if I can get it first try without having to redo anything, then maybe less than an hour.
And even then, this is just an educated guess since, again, I've done water filters but not air filters. Carbon is used to filter air too. Activated carbon is one of the materials that can be used to make diving re-breathers, so we know this is possible. But in the situation you describe, this would definitely not be the first thing I tried, and it might be the last.
Update: First attempt was not successful
I tried this out today. For the first attempt, I did not go all-natural. Instead, I used a disposable water bottle for the base, similar to the answer by Restless Adventurer. That should have made it easier, yet I still ran into problems.
The major problems with the device I made:
- Very difficult to breathe out. I would make a looser seal next time so air can escape around my mouth instead of trying to force it through the carbon filter.
- In was easy, but only because the carbon shifted out of the way and the air went around the carbon instead of through it. Next time I would try to use something to hold the dust in place better.
- Some of the dust came out into my mouth and lungs. Very unpleasant. Again, hold it in place better with something that the particles won't go around.
After the above changes, I fear that the air might have much difficulty coming in to inhale as well. Might need to make the powder layer less thick, though it already wasn't thick to begin with.
I would not dismiss this mask idea entirely, but it is not looking promising. I would not bother trying in survival scenario unless I had lots of time to tinker and could use the results in a controlled environment.