How to edit widget code to add unique class name to each div?

Not sure I entirely understand what you need – but try changing the else statement to this:

else {
    $service_class = "tg-one-third tg-item-" . $j;
}

It should add another class to each, i.e. ‘tg-item-1’, ‘tg-item-2’, etc. – allowing you to target those specific divs