How to display the "animate property" diamond keyframe insert button (2.8x)
UILayout.use_property_split and UILayout.use_property_decorate

Setting UILayout.use_property_split  in conjunction with  UILayout.use_property_decorate  to True, marks down the animation button. (Currently not over-documented)  My understanding is the split makes room for it, and the decorate draws it.



With developer extras on, right click > view source. Found this in bl_ui.properties_space.py giving a big hint

    layout.use_property_decorate = False  # No animation.


Quick demo with object location, using the Text Editor &gt; Templates &gt; Python &gt; UI Simple Panel template

import bpy


class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    def draw(self, context):
        layout = self.layout
        layout.use_property_split = True
        layout.use_property_decorate = True
        obj = context.object

        col = layout.column()
        col.prop(obj, "location")


def register():
    bpy.utils.register_class(HelloWorldPanel)


def unregister():
    bpy.utils.unregister_class(HelloWorldPanel)


if __name__ == "__main__":
    register()