Hello,
The task bars consist of div elements, there is no way to partially colorize the div element. But you can implement a custom solution for that.
However, probably, the easiest way would be to use the rollup functionality to show the child task bar over the parent task bar: https://docs.dhtmlx.com/gantt/desktop__milestones.html#rolluptasksandmilestones
You can check if a task is critical and change the rollup property of the task object.