The following is for a finite board (the question actually assumes an infinite board).

For an $N\times N \times N$ board, wouldn't $2N$ rooks suffice? The idea comes from adapting the checkmate with two rooks for the two dimensional case in which the two rooks alternate rows and force the king to the last rank.

For the three dimensional case, for each $y$ with $1\leq y \leq N$, place one rook at $(1,y,k)$ and another at $(2,y,k+1)$. Then, for $y$ going from $1$ to $N$, move the rook at $(1,y,k)$ to the square $(1,y,k+2)$. Again, for $y$ going from $1$ to $N$, move the rook at $(2,y,k+1)$ to $(2,y,k+3)$. Each for loop over $y$ involves moving, alternately, the rooks with $x$ coordinate $1$ by increasing their $z$ coordinate by $2$ units, or the rooks with $x$ coordinate $2$ by increasing their $z$ coordinate by $2$ units. We alternate, so that a for loop in which the rooks with $x$ coordinate $1$ are moved is followed by a for loop in which the rooks with $x$ coordinate $2$ are moved, and vice versa. Eventually, either the rooks with $x$ coordinate $1$ or the rooks with $x$ coordinate $2$ will have $z$ coordinate $N$.

The effect of this is that a subset of the squares guarded by the rooks form a "floor" of two layers that keeps moving upward. So if the black king is between this "floor" and the top of the $N\times N\times N$ cube, it gets pushed to the top face. The "floor" must be moved upward in such a way that it never becomes disconnected, so that the black king can never escape to beneath the "floor" through some gap.

For an infinite board, @Noam Elkies has already mentioned $5N$, so the following is not an improvement: the "ceiling" (and the other walls of the $N\times N \times N$ cube) can be formed by placing $N$ more rooks at $(N,y,N)$, for each $y$ with $1\leq y\leq N$, and $N-1$ more rooks at $(x,1,N)$, for each $x$ with $1 \leq x \leq N-1$, and $N-1$ more rooks at $(x,N,N)$ for each $x$ with $1 \leq x \leq N-1$.

encouragethe OP to alter the question instead? $\endgroup$31more comments