This is a pretty difficult task, if we’re being honest. People need to decide to stop themselves. You can encourage them to stop online gambling by self-excluding or at the very least taking a time out.
Self-exclusion is a long term break from online gambling, whereas a time out is only short term. During both, you can’t place wagers and they can’t be reversed. However, it’s still possible to bet elsewhere online and offline, so your friend needs to deal with the problem head-on.