Tracing the origin and evolution of interstellar water is key to understanding many of the physical and chemical processes involved in star and planet formation. Deuterium fractionation offers a window into the physicochemical history of water due to its sensitivity to local conditions. The aim of this work is to utilize the increased sensitivity and resolution of the James Webb Space Telescope (JWST) to quantify the HDO/H$_ $O ratio in ices toward young stellar objects (YSOs) and to determine if the HDO/H$_ $O ratios measured in the gas phase toward massive YSOs (MYSOs) are representative of the ratios in their ice envelopes. Two protostars observed in the Investigating Protostellar Accretion (IPA) program using JWST NIRSpec were analyzed: HOPS 370, an intermediate-mass YSO (IMYSO), and IRAS 20126+4104, a MYSO. The HDO ice toward these sources was quantified via its 4.1 mu m band. The contributions from the CH$_ $OH combination modes to the observed optical depth in this spectral region were constrained via the CH$_ $OH 3.53 mu m band to ensure that the integrated optical depth of the HDO feature was not overestimated. H$_ $O ice was quantified via its 3 mu m band. New laboratory IR spectra of ice mixtures containing HDO, H$_ $O, CH$_ $OH, and CO were collected to aid in the fitting and chemical interpretation of the observed spectra. HDO ice is detected above the 3sigma level in both sources. It requires a minimum of two components, one amorphous and one crystalline, to obtain satisfactory fits. The H$_ $O ice band at 3 mu m similarly requires both amorphous and crystalline components. The observed peak positions of the crystalline HDO component are consistent with those of annealed laboratory ices, which could be evidence of heating and subsequent recooling of the ice envelope (i.e., thermal cycling). The CH$_ $OH 3.53 mu m band is fit best with two cold components, one consisting of pure CH$_ $OH and the other of CH$_ $OH in an H$_ $O-rich mixture. From these fits, ice HDO/H$_ $O abundance ratios of 4.6pm 1.8times 10$^ $ and 2.6pm 1.2times 10$^ $ are obtained for HOPS 370 and IRAS 20126+4104, respectively. The simultaneous detections of both crystalline HDO and crystalline H$_ $O corroborate the assignment of the observed feature at 4.1 mu m to HDO ice. The ice HDO/H$_ $O ratios are similar to the highest reported gas HDO/H$_ $O ratios measured toward MYSOs and the hot inner regions of isolated low-mass protostars, suggesting that at least some of the gas HDO/H$_ $O ratios measured toward massive hot cores are representative of the HDO/H$_ $O ratios in ices. The need for an H$_ $O-rich CH$_ $OH component in the CH$_ $OH ice analysis supports recent experimental and observational results that indicate that some CH$_ $OH ice may form prior to the CO freeze-out stage in H$_ $O-rich ice layers.