A framework to test modified gravity using galaxy surveys