As Mike says in his comment, the answer is not known in full generality, not even for $n=2$, so for classes in $\mathbb{CP}^2\#\mathbb{CP}^2$. I think the paper that he links (https://arxiv.org/abs/2210.12486, by Marengon, Miller, Ray, and Stipsicz) describes the state of the art for $n=2$.
Some results are known for certain specific families of homology classes (for arbitrary $n$).
Characteristic classes: these are homology classes in which all coefficients are odd (with respect to the standard basis). Since the complement of any surface in this homology class is spin, you can use the Rokhlin invariant/Rokhlin's signature theorem to exclude the existence of spheres in these homology classes. This is sometimes known as the Kervaire-Milnor obstruction (On 2-spheres in 4-manifolds, Proc. Nat.
Acad. Sci. U.S.A. 47 (1961)), and it says that $A^2 \equiv n \pmod{16}$ if the class $A \in H_2(n\mathbb{CP}^2)$ is characteristic and represented by a smoothly embedded sphere.
Divisible classes: these are classes that are (non-trivial) multiples of another class. Here you can use cyclic branched covers (and the G-signature theorem) to give lower bounds. (And these bounds also work in the topological category, by the way.) This is probably explained in Gilmer's paper on configurations of surfaces, together with much more general results (Configurations of surfaces in 4-manifolds, Trans. Amer. Math. Soc. 264 (1981)).