1. Yes. Correct.
2. Not quite, because the second option "they say we have avenged the prophet" makes we (you and I) the people who said those words, rather than the gunmen. However, using quotation marks, you could say the following, and still make that sentence work:
They shouted "we have avenged the Prophet Muhammad".
This then attributes the quotes to the gunmen, rather than adding the pronoun "we" out of context, which would then turn ownership of those words to an external we, such as you and I.
Hope this helps.