Is there any command to evaluate in PARI GP such sum: $\sum\limits_{\substack{2\leq d\leq n \\ (d, n)=1}}\frac{a\left(n \right)}{d}$ ? In other words: how to add to command
sum(d=2, n, \frac{a(n)}{d})
condition from second line ($(d,n)=1$).(or more such conditions)
There is no built-in way, but it's easy to program. Let's simplify your question to computing $$\sum_{2\leq d \leq n\atop (d,n)=1} a(d) $$ This can be done as follows:
In many concrete cases, $a(d)$ will be a multiplicative function, and the sum can first be rewritten as a product over primes (less than $n$ and not dividing $n$).