Depends on the dog. If they're chasing for fun or because it's in their genes to herd - think Border Collie - it would probably deter them. If they're highly adrenalized, an air horn may tip them into more aggression.

A very stern "GO HOME" can work. If you can't out sprint them, sometimes stopping pedaling works (along with GO HOME) because the turning of your feet can be exciting & make the dog want to nip - again, think Border Collie. But if it's Cujo - I'd want to try to outrun them, if I could. Some people use bear spray. I've never tried it but I imagine it would be pretty nasty stuff.

If you have to get off the bike, try to keep the bike between you & the dog. And yell like crazy.