Follow the bellow steps to change GeoLocation in Firefox using Selenium:
Create a Firefox profile:
  1.  Start the Firefox Profile manager with: firefox.exe -P and create a new profile.
  2. Open about:permissions in the browser
  3.  Locate the entry of the website and change Share Location from Always Ask to Allow

Create a JSON file with a GeoLocation:

Example File "geoLocation.json" as shown below
     {             
"status": "OK",
"accuracy": 10.0,
"location": {"lat": 13.0839, "lng": 80.2700}
    }
Set the geo.wifi.uri firefox profile preference before launching the browser. Finally the code look like as shown below

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.testng.annotations.*;
public class ChangeGeoLocationTest
{
                private static WebDriver driver;
                @BeforeClass 
                 public void setUp()
                {
FirefoxProfile profile = new ProfilesIni().getProfile("dev"); profile.setPreference("geo.wifi.uri", "file://D:/geoLocation.json");
driver = new FirefoxDriver(profile); driver.get("http://www.w3schools.com/html5/html5_geolocation.asp");
                }
                @AfterClass 
                 public void tearDown()
                {
                                driver.close(); driver.quit();
                }
                @Test 
                 public void getLocation() throws InterruptedException
                {
                                driver.findElement(By.cssSelector("p#demo button")).click();
                                Thread.sleep(5000);
                }
}