The generaliztaion of Macaulay duration (which is defined in terms of yield to maturity) is known as Fisher-Weil duration. How is Fisher-Weil duration or modified duration defined under non-parallel shift in spot curve?
When you want to consider arbitrary (i.e. non parallel) movements of the yield curve, the duration ( a scalar) is replaced by a vector of 'key rate durations' one for each maturity you wish to consider. investopedia.com/terms/k/keyrateduration.asp