Indeed, that would be easy enough. But most engines use 1-dimensional arrays for speed (if they use a mailbox representation), so you would still have to define a mapping of x,y,z to an array index.
Even 2d programs like the Interactive Diagram can mimic 3d or 4b space boards, though. On chessvariants.com I have seen several of those. The point is that representation on a computer display is inherently 2d. So such variants are typically displayed as a table of 2d boards, each such 2d board representing a layer of the larger space. Moves in the 3rd or 4th dimension then simply jump between boards, which can be mimicked by giving the piece a large leap, and putting the layer boards far enough from each other such that the in-layer moves cannot cross the separation band.
But in a typed language like Cor C++ engines for orthodox Chess often assume that the square numbers fit in a single byte, and move descriptors in a pair of bytes. So you would still have to make many changes because the 3d space has too many cells.