Elon Musk has brandished a chainsaw on stage and defended his slashing of US government spending in a bizarre appearance.