Yes, they can cast a spell instead of an opportunity attack when an enemy moves away from their echo
The War Caster feat (PHB, p. 170) states that you can cast a spell instead of making an opportunity attack "when a hostile creature's movement provokes an opportunity attack from you" (emphasis mine).
Initially, I was tempted to say that the opportunity attack is provoked from the Echo, not "you". However, the text for the Echo Knight's Manifest Echo feature (EGtW, p. 183) is quite clear that you make the opportunity attack from the echo's position; therefore, the attack is eligible to be replaced by a spell.
However, as illustrated by V2Blast's answer in this follow-up question, the spell originates from youyour space, not your EchoEcho's.