Yes, margin trading is legal in most countries. With that said, there are strict regulations in place to ensure inexperienced traders do not lose more money than they can afford to lose.