There are only four, but you'll never be able to guess them all, not even from looking at the flags.
Saudi Arabia, Iraq, Iran and Afghanistan. Saudi Arabia and Iraq are easy to spot. The former has the shahada, the second says Allahu akbar. Afghanistan also has the shahada, but it's very small, hidden in the coat of arms.
You'd be forgiven for not spotting any script on the Iranian flag, but the pattern running in the green and red fields says Allahu akbar too - for a total of 22 times. Moreover, the coat of arms in the middle may be interpreted as a stylised writing of Allah, made to look like it's made up of crescents and a sword and arranged in the shape of a tulip, the flower that grows from the blood of the martyrs.
The Comoros also used to have a flag which said Allah and Muhammad, the flag of Afghanistan under the Taliban had the shahada, and the ISIL flag says Allah rasul (prophet) Muhammad in the centre. That's all I know of.