For the first time in two decades, residents of a Hamas-run city in Gaza have been allowed to vote in a Palestinian election as a show of unity.