She passed the exam at the top.

Literal

She [topic-は] exam [target-に] top [as-で] passed.

The katakana loanword トップ (from English 'top') functions here as a noun meaning 'first place / number one.' で marks the manner or capacity in which she passed — 'as the top scorer.' This is the same で seen in 一人で ('by oneself / alone'), 大声で ('in a loud voice'), and 現金で ('in cash'), used here in its 'in the role/condition of' sense. トップで合格する is a stock collocation for placing first on an exam, audition, or competitive ranking.