How to control the display's backlight in the sketch?

There is no backlight control other than the trimmer pot, so I have to find a solution

With out understanding of what the trimmer does, you cannot have a solution: the trimmer could be outputting a signal that the display uses to change backlight, or it could be the resistance in the backlighting leds....

Getting the datasheet or the schematic is your quickest and surest solution.

Short of that, trace the pcb and experiment.