Not knowing what technology you are using to create this forum, it’s pretty difficult to tell you how to achieve this.
Also, not knowing what you already know makes it hard to know where to start helping you.
There are forum software solutions that already have this feature - such as Discourse, which powers this forum.
Since you’ve already got something up and running, presumably you don’t want to switch software - though, to be frank with you, using Discourse would give you a much more modern looking forum.
I’ve never done this, but essentially I would approach this by thinking along the following lines:
Every time a user posts something, part of my backend script handling it would have to parse it for @mentions
Then, if the @mention is for a valid user, and they are connected (friends, followers, etc, depending on the permissions for your system), then I might push the post to an array like object in the recipient’s database record (depending on your DB setup - if this were Mongo, I’d have it living in the user model, most likely…if SQL based, maybe a separate transactional table?)