The ruling rejected the Trump administration’s attempt to change federal election procedures through an executive order.