Let $g = [g_{1} g_{2} \dots g_{r}] \in \Bbb Z_{q}^{*r}$ be a given vector with each $g_{i} \in \Bbb Z_{q}^{*}$ where $\Bbb Z_{q}^{*}$ is $\Bbb Z_{q} \backslash \{0\}$ and $q > 6$ is odd. How many vectors $a = [a_{1} a_{2} \dots a_{r}] \in \Bbb Z_{q}^{r}$ with each $a_{i} \in \Bbb Z_{q}^{}$ are such that:
$(1)$ $a^{T}g = 0$?
$(2)$ $a^{T}g = 1$?
First of all, by the Chinese Remainder Theorem, it suffices to consider prime powers $q$. For composite $q$, the number of solutions will be the product of the solution numbers for the respective prime power parts of $q$.
So assume $q = p^m$, $p$ prime. For elements $a\in\mathbb{Z}/q\mathbb{Z}$, we define the $p$-adic valuation $v_p(a)$ as the maximum exponent $e$ such that $p^e \mid a$. In the special case $a=0$, we set $v_p(a) = m$. Now set $N = \min\{v_p(g_i) \mid i\in\{1,\ldots,r\}\}$.
For Question 1, the answer is $q^{r-1}\cdot p^N$. This can be proven by induction over $m$, for example.
Apparently, Question 2 doesn't have a solution if $N \neq 0$. For $N = 0$, the number of solutions is $q^{r-1}$. (Let $i$ be a index with $v_p(g_i) = 0$. Then $g_i$ is a unit. Now for each choice of the $r-1$ entries $a_j$ with $j\neq i$, there is a unique $a_i$ s.t. $a^T g = 1$.)