Let the white balls form a set $\mathcal W$ of size $N_1$ and the black balls form a set $\mathcal B$ of size $N_2,$ both of which are disjoint subsets of the set of all $N$ balls, $\mathcal U.$
For any ball $i\in \mathcal U,$ let $X_i$ be the indicator that ball $i$ is included in the sample $\mathcal S:$ that is, it equals $1$ when $i\in S$ and otherwise equals $0.$ The process of sampling makes these $X_i$ into random variables, because associated with any sample $\mathcal S$ is the vector of values of all the $X_i$ corresponding to $\mathcal S.$
Indicators enjoy nice connections with the underlying probabilities. In particular, notice that since $X_i^2 = X_i,$
$$E[X_i^2] = E[X_i] = \Pr(X_i=1)1 + \Pr(X_i=0)0 = \Pr(X_i=1) = \Pr(i\in\mathcal{S}).$$
Let's pause to work out some important probabilities. To say the sample has size $n$ is equivalent to saying the sum of the indicators is $n:$
$$n = \sum_{i\in\mathcal U}X_i.$$
Since in simple random sampling all balls have equal chances $\pi_i = p$ (say) of being in the sample, by taking expectations we deduce
$$n = E\left[\sum_{i\in\mathcal U}X_i\right] = \sum_{i\in\mathcal{U}} E\left[X_i\right] = \sum_{i\in\mathcal{U}} \pi_i = \sum_{i\in\mathcal{U}} p = Np,$$
whence
$$\Pr(i\in\mathcal S) = \pi_i = p = \frac{n}{N}.$$
Similarly, given two distinct balls $i$ and $j\ne i,$ the chance that both $i$ and $j$ are in the sample (which I will write as $\pi_{ij}=q,$ which also does not depend on $i$ or $j$) can be found by taking expectations of the product $n\times n$ expressed as sums of indicators:
$$\begin{aligned}
n^2 &= E[n^2] = E\left[\sum_{i\in\mathcal{U}} X_i\, \sum_{j\in\mathcal{U}}X_j\right]\\
&= \sum_{i,\,j} E[X_iX_j]\\
&= \sum_i E[X_i^2] + \sum_{i\ne j}E[X_iX_j]\\
&= \sum_i E[X_i] + \sum_{i\ne j}\pi_{ij}\\
& = Np + N(N-1)q\\
&= n + N(N-1)q,
\end{aligned} $$
whence
$$\Pr(i\ne j\in\mathcal S) = \pi_{ij} = q = \frac{n^2-n}{N(N-1)} = \frac{\binom{n}{2}}{\binom{N}{2}},$$
the same result one would get from a combinatorial argument.
Returning to the question, we now have enough information to compute variances and covariances. For example, with $i\ne j,$
$$\operatorname{Cov}(X_i,X_j) = E[X_iX_j] - E[X_i]E[X_j] = q - p^2 = -\frac{n(N-n)}{N^2(N-1)}$$
and, similarly,
$$\operatorname{Var}(X_i) = E[X_i^2] - E[X_i]E[X_j] = p - p^2 = \frac{n(N-n)}{N^2}.$$
Finally, we may compute variances and correlations of the $Y$'s by expressing them as suitable sums of indicators and applying the bilinear property of covariance. For instance,
$$\begin{aligned}
\operatorname{Cov}(Y_1,Y_2) &= \operatorname{Cov}\left(\sum_{i\in\mathcal W}X_i,\sum_{j\in\mathcal{B}} X_j\right)\\&= \sum_{i\in\mathcal{W},\,j\in\mathcal{B}}\operatorname{Cov}(X_i,X_j)\\&= N_1\,N_2\left(-\frac{n(N-n)}{N^2(N-1)}\right)\end{aligned}$$
because $\mathcal W$ and $\mathcal B$ are disjoint. This agrees with the formula quoted in the question.
You have now seen examples of all the techniques needed to complete the calculation of the correlation coefficient of $Y_1$ and $Y_2.$ (When computing $\operatorname{Var}(Y_k),$ you will need to split the sum into separate sums of variances $\operatorname{Cov}(X_i,X_i)=\operatorname{Var}(X_i)$ and covariances $\operatorname{Cov}(X_i,X_j),$ $j\ne i,$ much as I did in the calculation of $E[n^2],$ so make sure you're comfortable manipulating such double sums.)
In the spirit of self-study questions I will stop short of a complete answer.