How can I triangulate a position using two DMEs?
We can find the exact method to use online, after all this is a common 3D trigonometry problem. I'll use Michael Geyer 
US DoT report: Earth-Referenced Aircraft Navigation and Surveillance Analysis. The principle is:


The two DME distances determine two spheres which intersection is a circle. The aircraft is on this circle.
The aircraft altitude determines a surface (depending on how altitude is measured, it can be a quasi-plane or a surface of constant pressure) which intersects the circle at two points. The coordinates of the points can be computed from the two DME distances and the altitude.
As a matter of fact DME signals at the two points are identical, therefore one must be eliminated by some method.


Intersect two spheres to get a circle

The slant distance determined with DME tells us the aircraft is on the surface of a sphere centered at the DME station, with radius equal to the slant distance. By interrogating two DMEs, two intersecting spheres are determined. The intersection is a circle (pink circle in the figure below). The closer the aircraft is to the line joining the two DME stations (the baseline), the smaller the circle, down to a single point when the aircraft is exactly on the baseline.

  

Intersect the circle with a surface to get two points

The aircraft is flying in a quasi horizontal plane. This plane intersects the circle at two locations (green points in the figure above) which are symmetrical to the baseline and where the aircraft must be located. By using the direct information we have (altitude and slant ranges), we can compute the coordinates of the two points.

Eliminate the ghost location

At a given time, the aircraft could be located at either points and still receives the same DME signals. In the mathematical solution, this will appear when using a function like $\arcsin(x)$, which gives two angles for the same x value, e.g. 40° (90°-50°) and 140° (90°+50°).

There are several methods to eliminate the virtual position:


Monitor the progress of the aircraft: If the aircraft flies north, the top point moves north while the bottom point moves south. We can detect such illogical trajectory (e.g. using a predictive Kalman filter).
Use a third DME: The third range sphere will intersect the other two at only one point.
Determine aircraft bearing using a VOR, preferably collocated with one of the DME.


In large aircraft, position is determined using multiple means including inertial and GNSS, so it's not difficult to know where the aircraft is approximately.

Determination of the points coordinates

The DME/DME/Elevation case boils down to:

  


  
  Two DME stations $\small U$ and $\small S$ with known latitudes, longitudes and altitudes ($\small L_U$, $\small \lambda_U$, $\small h_U$ and $\small L_S$, $\small \lambda_S$, $\small h_S$).
  An aircraft A with known altitude ($\small h_A$).
  Two measured slant distances ($\small d_{UA}$ and $\small d_{SA}$)
  


$\small C$ is earth center (earth radius is $\small R_e$. Following the method mentioned previously, we execute these steps:


  
  Step 0: Convert slant-ranges to angular distance
  Step 1: Solve the spherical triangle for each station
  Step 2: Confirm inputs are consistent and a solution exists
  Step 3: Solve the spherical triangle USA
  Step 4: Compute aircraft latitude and longitude
  


Step 0: Convert slant-ranges to angular distance

With altitudes and slant ranges known, it is possible to calculate angles $\small \theta_{SA}$ ($\small \widehat{SCA}$) and $\theta_{UA}$ ($\small \widehat{UCA}$) between DME and aircraft. For each DME $\small x$ ($\small x$ being either $\small U$ or $\small S$):

$$\theta_{xA} = 2\space \arcsin \left( \frac{1}{2} \sqrt{\frac{(d_{xA}-h_A+h_x)(d_{xA}+h_A-h_x)}{(R_e+h_x)(R_e+h_A)}} \right)$$

By convention we need to name $\small U$ the station which is westward. This allows us to refer at the aircraft position like "the one south of the baseline".

Step 1: Solve the spherical triangle for each station

The first actual step is to get the angle $\small \theta_{US}$ formed by the two DME stations and earth center:

$$\sin \left( \frac{1}{2}\theta_{US} \right) = \sqrt {\sin^2 \left( \frac{1}{2}(L_S-L_U) \right) + \cos(L_S) \cos(L_U) \sin^2 \left( \frac{1}{2}(\lambda_S-\lambda_U) \right)}$$

where $\small L_U$ and $\small L_S$ are latitudes of $\small U$ and $\small S$ and $\small \lambda_U$ and $\small \lambda_S$ are longitudes of $\small U$ and $\small S$.

We will need to know one of the azimuth at the extremities of the baseline between $\small U$ and $\small S$:

$$ \tan(\psi_{S/U}) = \frac {\cos(L_S) \sin(\lambda_S - \lambda_U)} {\sin(L_S) \cos(L_U) - \cos(L_S) \sin(L_U) \cos(\lambda_S - \lambda_U)} $$

Step 2: Confirm inputs are consistent and a solution exists

If the slant ranges are 10 NM and 15 NM, and the known distance between stations is 30 NM, then there is no actual solution, something must be wrong. This step checks whether the two DME range spheres intersect. We have already computed angles $\small \theta_{UA}$ and $\small \theta_{SA}$ and the one between stations $\small \theta_{US}$:


If $\small \theta_{UA} + \theta_{SA} &lt; \theta_{US}$, then the spheres don't intersect (centers too remote)
If $\small \left| \theta_{UA} - \theta_{SA} \right| &gt; \theta_{US}$, then spheres are concentric, they don't intersect.


Step 3: Solve the spherical triangle USA

Now we know the three sides of the triangle $\small \widehat{USA}$, we can determine any of its angles. We need only the angle with its apex at one station:

$$\cos(\beta_U) = \frac {\cos(\theta_{SA}) - \cos(\theta_{US}) cos(\theta_{UA})} {\sin(\theta_{US}) \sin(\theta_{UA})}$$

Step 4: With all data now available, compute aircraft latitude and longitude

It's time to decide which of the two aircraft positions we want by selecting the corresponding azimuth angle at station $\small U$ (it could be at $\small S$, but we did the previous step for $\small U$):


If $\small A$ is south of $\small US$ baseline (assuming $\small U$ is west of $\small S$): $\small \psi_{A/U} = \psi_{S/U} + \beta_U$
If $\small A$ is north of $\small US$ baseline: $\small \psi_{A/U} = \psi_{S/U} - \beta_U$


Aircraft latitude $\small L_A$:

$$\sin(L_A) = \sin(L_U) \cos(\theta_{UA}) + \cos(L_U) \sin(\theta_{UA}) \cos(\psi_{A/U})$$

Aircraft longitude $\small \lambda_A$:

$$\tan(\lambda_A - \lambda_U) = \frac {\sin(\psi_{A/U}) \sin(\theta_{UA})} {\cos(L_U) \cos(\theta_{UA}) - \sin(L_U) \sin(\theta_{UA}) \cos(\psi_{A/U})}$$



I posted a Python implementation on Stack Overflow.