Consider $$1 \over \sin (x - a) \sin (x - b)$$
I rewrite it as $${A \over \sin (x - a)} + {B \over \sin (x - b)} = {1 \over \sin (x - a) \sin (x - b)}$$
Then multiplying by $\sin (x - a)$,
$$A = {1 \over \sin (x - b)} - {B\sin (x - a) \over \sin (x - b)}$$
If I put $x = a$, then I get $$A = {1 \over \sin (a - b)}$$,
Similarly I get $$B = { 1\over \sin(b - a)}$$.
But this does not seem correct as I plugged it back in and I don't get the original function.
What is the general way of doing partial fraction for trigonometric functions like $$1 \over \cos(x - a)\cos (x - b)$$ or the example above.
The partial fration method that you advocate (with constants in the numerators) only works for polynomials. So your ansatz
$$ {A \over \sin (x - a)} + {B \over \sin (x - b)} = {1 \over \sin (x - a) \sin (x - b)} $$ will produce wrong results.
A more general way of proceeding is to write the numerators as functions:
$$ {A(x) \over \sin (x - a)} + {B(x) \over \sin (x - b)} = {1 \over \sin (x - a) \sin (x - b)} $$
Clearing denominators gives $$ 1 = {A(x) \sin (x - b)} + {B(x) \sin (x - a)} $$
Since $ \sinα \cos β= 1/2 (\sin(α - β) + \sin(α + β))$ and $ \sinβ \cos α= 1/2 (- \sin(α - β) + \sin(α + β))$ one can write $A(x) = q \cos(x-a)$ and $B(x) = - q \cos(x-b)$ with some constant $q$ to be determined. This gives
$$ 1 = {q \cos(x-a) \sin (x - b)} - {q \cos(x-b) \sin (x - a)} = q \sin(a-b) $$
so
$$ q = \frac{1}{\sin(a-b)} = \operatorname{cosec} (a-b)$$
as required. The general way of proceeding is to make use of those trig relations.
By the same method, you get
$$ {1 \over \cos (x - a) \cos (x - b)} = - \operatorname{cosec}(a - b) \left({\sin (x - a) \over \cos(x - a)} -{\sin (x - b) \over \cos(x - b)} \right) $$