A teenager who pulled out a zombie-style machete after slapping his mother in a violent attack on his family started coughing up blood in court.