Former drug dealer is sworn in as attorney by judge who challenged him to change his life