As others have stated, yes you could use stomach acid as a weapon. I would agree with L.Dutch though that they would likely have dedicated acid stacks rather than using the acid in their stomach for practical reasons. (Perhaps acid is produced and stored in these sacks, one tube leads to the stomach to fill the stomach with acid, another tube leads up towards the dragon’s head). You would need some kind of protection against the acid in the mouth, acid sacks and the tubes leading to the stomach and mouth.
If you wanted to get a bit fancier, rather than just having a tube in the dragon’s mouth that ejects the acid, you could have the tube run up to some fangs. This way you could have your dragon either spray out the acid or inject it into their prey.
Rather than just using plain old stomach acid, we might be able to do one better. By combining various acids, we can create one which has a negative PH level. You may be able to have two different acids produced and stored in separate sacks. When the dragon wants to use it as a weapon, some acid from each sack is ejected, causing them to mix. Now, i don’t know of this would be biologically possible as i’m not certain of the manufacturing process of super acids, however if it is you may want to consider this.
Instead of using acids, you may want to use enzymes. Whilst acids will burn someone they might not break down fats, which makes up a large portion of an animal’s body. However, if you instead fire out enzymes that break down a creatures body, it would likely cause the burning sensation you are after whilst also pre-digesting a dragon’s food to some degree.