How to substitute a character depending on the one or two after it?

My Version is 11.5 and please help!
For example,
a b → c b;
a b c → d b c.

Moved to support

It is hard to understand why you need this. Please explain.

Perhaps the Randomize Feature will be of interest to you?

You need a chained context substitution and single substitution lookups as shown here:
abc-to-dbc.png
A basic script that you can import looks like:

script latn {
  feature ContextualAlternates1;
}

feature ContextualAlternates1 calt {
  lookup ChainingContext1;
}

lookup ChainingContext1 {
  context a (b c);
  sub 0 SingleSubstitution1;
  context a (b);
  sub 0 SingleSubstitution2;
}

lookup SingleSubstitution1 {
  sub a -> d;
}

lookup SingleSubstitution2 {
  sub a -> c;
}

Oh thanks a lot! (๑•̀ㅂ•́)و✧

And what should I do if I want to do like this:
a b c → a d c