How to set Dynamically 'Config True/False'

Hello,

I wonder If there is a way to set leaf to ‘Config True/False dynamically’.

for example, There are 2 YANG Leaf, A and B.
if A value = ON, then B is ‘config true’
else A value = OFF, then B is ‘config false’.

and There should be no issue for loading DB, when the system reforks or restarts.

No, you cannot change node’s config/state flag dynamically. You can do something that may look a bit like what you are trying to achieve using when:

leaf A {
  type boolean;
  default true;
}
container config {
  when '../A = "true"';
  leaf B {
    type string;
  }
}
container non-config {
  when '../A = "false"';
  config false;
  leaf B {
    type string;
  }
}

If that does not solve your problem, try to describe your use-case in more detail, maybe there are other ways to approach it.