Yes you can, the walls spring into existence, therefore anything within the cube that's is blocked by the walls is simply stuck inside until the cube is deactivated.

Ref. DMG pp159-160

> ... Otherwise a barrier of invisible force springs into existence, forming a cube 15 ft on a side.
> The barrier is centered on you, moves with you, and lasts for 1 minute...