There is no inherent immunity against friendly ECM. Depending on exact method used, the more advanced ones are capable of acting against specific emitter types, however, more... brute force approaches rely more on jamming being directional, effectively radiated towards the enemy systems, but this can still cause issues on friendly systems as well.
When cleverly selected, advanced ECM techniques can, in principle, be rather powerful against the enemy and almost completely harmless against the friendly systems. However, this would require very good understanding of the enemy systems probably encountered to precisely affect them adversely while sparing the own ones. In practice, this would likely limit the use of this into specific, high priority operations that can afford the element of surprise and all the necessary intel.
Recall, being specific against the enemy emitters that we are willing to jam allows the enemy to use that specificity against us as well, by altering those very specific characteristics of the system enough for the jamming system not being specific-enough anymore in selectivity against that very system. Also, militaries are expected to have 'for-shooting-war-only' modes in their most important radar systems as a simple measure to avoid too easy emitter-specific ECM against them.
The latest developments in processing power and in things such as AI could have opened up some interesting approaches in how to interfere with specific emitters in clever ways, however, I have not studied the fields related to those topics enough to throw any generic thoughts whatsoever with practical sense at all.