You can achieve that by using before or after Invocation testng listener method. If
Here is an example how you can access metadata from ItestReuslt object:
@Override
public void beforeInvocation(IInvokedMethod method, ITestResult tr) {
TestNGScenario scenario = (TestNGScenario) tr.getMethod();
//do the needful
scenario.getMetaData().put("referenceUrl",value);
}
You also can get ITestResult object for current running test outside listener using ApplicationProperties.CURRENT_TEST_RESULT.key. For example
ITestResult tr = (ITestResult)getBundle().getProperty(ApplicationProperties.CURRENT_TEST_RESULT.key)