I am not a US citizen or resident. I suppose to get money from a US company so I have to fill a W-8ben form. I want the company to transfer the money to a bank account of a friend of mine. In such case, when I fill the form should I add my name as the beneficial or my friend's ?
I suspect you would need to enter your friend's name in the payment information section, because when the money is deposited, the bank account is identified by the name and account number among other things. I believe it's a safety measure to prevent accidentally sending money to the wrong person. In any case, you usually can't just wire money to "John Doe at account X" if account X is actually held by Richard Poe.
However you should contact the HR department of the company, they can talk to accounting/payroll and decide what you should do depending on how your particular company actually executes the deposits.