Yes. Masks can filter out even the smallest particles – those a tenth the size of viruses. What’s more, they work surprisingly well even while people are wearing them. Surgical ones are cheap and more readily available, and they do surprisingly well at filtering virus-sized particles.
However, masks cannot guarantee 100% protection from the coronavirus. They should be used in combination with other methods to reduce the exposure and risk of virus transmission.