For a matrix with $A^2=0$ assuming it be different from null matrix because for the null matrix the case the result is trivial.
Consider $A^2=0$ , $m_A(x)=x^2$
There exists a Jordan block corresponding to the eigenvale $0$ of size $2×2$. And every jordan block corresponding to the eigenvalue $0$ of size $n×n$ has rank $n-1$. So in order to maximize your rank of the matrix you can have jordan blocks of size $2×2$ and not more than this size due to the restriction by the minimal polynomial. So you can have $5$ blocks ,each increasing the rank of the matrix by $1$.so maximum rank can be $5$
In general a matrix $A$ of size $n×n$ such that $A^2=0$
has rank atmost $\lfloor \frac{n}{2}\rfloor$