In reply to Shanmugam5577:
Most system tasks/functions can be overridden by simply registering a new VPI routine with the same name (Check your tool’s User Manual for any optimizations you may have to disable).
You can use a special string like “modification on/off” to control when to make the modifications. The only problem is it’s easy to format the output with the modifications you want, but it’s much more difficult to recreate the original unmodified output. That’s because SystemVerilog $display format strings are not completely compatible with C printf format strings. For example, there is no binary %b format in C. You would have to parse the format string and write your own conversion routines.
It might be easer to post-process the log file with you favorite scripting language.