The best way to do this is to run up towards the edge while doing a Hyphen Smash. In case you don't already know what a Hyphen Smash is, it's when you run and use your up smash. You can hold the up smash in place or you can release it on contact. This is somewhat difficult to pull off on your opponent as well as learn. While doing the Hyphen Smash, Ness slides a bit. You can see better results on a slippery floor. Using the Yo-yo normally on the edge obviously won't work.
It's difficult to use on opponents who hang on the edge because they can release and grab the edge again giving them invincibility frames. This is a great way to spike your opponent off the stage, but difficult since you can get punished for it. But yeah, practice on any stage and you should have it down in no time! You don't need any opponents around to practice this, either. If you have anymore questions, I'll do my best to share some info with you. Just ask away. :D