[subject] + 把 + [noun] + 当作 / 当成 / 当 + [noun]
[noun] + 被 + [person] + 当作 / 当成 + [noun]
把 + A + 当作 + B says someone treats A as B, or takes A to be B. 当 here is read dàng, not dāng.
Either can do either job. 当成 is the usual choice for a mistake, often with 了; 当作 (also written 当做) suits a role you give something on purpose.
Speech often drops 作 and keeps bare 当.
A goes after 把 and B after 当作. English "treat him as a friend" puts the person straight after the verb.
With 被, A comes first as the subject, and the person doing the treating follows 被, or is left out.