How to display custom panel in two spaces?
Subclasses and inheritance

Code based on this answers and updated for 2.8x according to API changes: 

class MY_PT_CustomPanel(bpy.types.Panel):
    """A Panel to show in many places"""
    bl_label = "My Tools Panel"
    bl_region_type = 'UI'

    def mydraw(self, context):
        # do nothing here so each class can add it's own thing'
        pass

    def draw(self, context):
        self.mydraw(context)
        row = self.layout.row()
        row.label(text="Hello world!", icon='WORLD_DATA')

class MY_PT_Viewport(MY_PT_CustomPanel):
    bl_space_type = 'VIEW_3D'

class MY_PT_ImageEditor(MY_PT_CustomPanel):
    bl_space_type = 'IMAGE_EDITOR'

    def mydraw(self, context):
        row = self.layout.row()
        row.label(text="For the Image editor")