An inmate was shot and killed in a struggle over the gun of a deputy assigned to watch him at a Texas hospital, authorities say.