There are lot of examples on how to control the appearance of grid body cells and rows ( conditional and non conditional ) by column.render, rowInit, pq_cellattr, pq_rowattr, pq_cellcls, etc.
For header title cells, it can be done only by adding a css class in column or by implementing column.title as a callback.
For example grid title cell appearance can be changed for filtered columns:
https://paramquery.com/forum/index.php?topic=2400.0For sorting the logic would be similar to above except you use sort event and use ui.sorter inside the event to get information about sorted columns.