forum_name() requires you to pass the forum_id to it. one way of doing is to get the forum_id for the topic_id and then call it. in other words create a function which takes topic_id as argument and do a mysql query to find out the forum_id & then call it.
I don’t think there is a bb-template function which can do that. you can try coding it. its easy enough.