Photo Credit: Courtesy of 3DStockPhoto ( image)
The patents that cover Lego bricks have expired, so you are free to print bricks using the same interlocking system. You are even allowed to offer such prints commercially.
What is not allowed (and a violation of trademark law) is to call them "Lego bricks" or use Lego's logo. "Compatible with Lego" on the other hand, would be fine.