The Democratic-backed candidate for Wisconsin Supreme Court has won, defeating President Donald Trump's endorsed challenger.