Victory lifted RB Leipzig, last season's Bundesliga runners-up, to six points and into third place, ahead of their opponents on goal difference.
RB Leipzig had a good chance in the first half but Jean-Kevin Augustin's effort bounced off the post as they took the initiative from the start.
Hamburg were then saved by the video assistant referee on the stroke of half-time when Werner was brought down in the box and the referee initially pointed to the penalty spot before changing his mind after asking for a video replay.
The hosts, looking to make it three wins in a row at the start of a season for the first time since the 1974-1975 campaign, again survived early RB Leipzig pressure in the second half.
But goalkeeper Christian Mathenia could do nothing when Keita, who will join Liverpool next season, thundered in an unstoppable shot in the 67th minute.
Germany international Werner then charged through and finished his solo effort seconds after Hamburg missed a golden chance to level in the 75th minute.