Templating - Get a string of the entry's field handle
You won't be able to do it that way because entry.field2 will return you the normalized field value and there is no way to trace back some object|string|variable to an unknown entry with an unknown field handle. You need to pass the handle as a second parameter in your macro

{% macro myMacro(field, fieldHandle) %}
    {{ fieldHandle }}
{% endmacro %}

myMacro(entry.field2, 'field2').


You could also pass the entry and a field handle instead of the field

{% macro myMacro(element, fieldHandle) %}
    {{ fieldHandle }}
    {% set value = element.getFieldValue(fieldHandle) %}
{% endmacro %}

myMacro(entry, 'field2').