Encode a signed integer as a zigzag encoded signed integer.

def SignedVarintEncode(value):
  """Encode a signed integer as a zigzag encoded signed integer."""
  result = b""
  if value < 0:
    value += (1 << 64)

  bits = value & 0x7f
  value >>= 7
  while value:
    result += HIGH_CHR_MAP[bits]
    bits = value & 0x7f
    value >>= 7
  result += CHR_MAP[bits]

  return result