We know that in Latin (LTR) the diacritic can appear in front of the letter, for example the letter “Ç” (Cedilla), we can add color to the diacritic “¸” and the color will be in front of “C”, while this is the contrary in RTL text, the diacritic will be behind the letter like this:
This depends on the application/text rendering pipeline. There is no standard here. Some (most?) applications will always draw glyphs from left to right, which means the last glyphs in RTL text will be drawn first, the the madda will be drawn then the alef. Fewer applications draw the glyphs for RTL text from right to left and they would then give the output you want.
OenType spec does not specify either way, and fonts have no direct way to influence it. One hack would to decompose your glyphs in the reverse order i.e. madda + alef instead of alef + madda, but then you would lose mark positioning.
@khaled Thank you so much for this comprehensive explaining. In this case I will try to raise a request to Adobe feature request platform to afford such possibility in InDesign or I’ll try how to make script for the purpose and have it available for all InDesign users who work on Arabic books that deal with colorful diacritics (children books specially) and I hope if there’s somebody ready to team up.