Brightness up/F2 button stopped working on my 2014 rMBP
Are you 100% certain that this is a hardware fault?

The best way to verify this is to find an application that allows you to set a keyboard shortcut and try pressing the fn + F1 key if this works then try setting it again with the broken key fn + F2.

If this doesn't work it strongly suggests your keyboard button is actually broken, in which case you would need to take it in to a repair center for diagnosis.

Could you tell us more about the exact model you have so we could advise if there are any open repair programs, all MacBooks with the new style butterfly keyboard are under a keyboard repair programme, if you have one of these it might be a free repair.